Skip to main content

The MoaT-Codec library

% start synopsis % start main

This library packages various codecs used for MoaT protocols in a way that's reason- and stream-able.

% end synopsis

Supplied codecs

  • CBOR
  • msgpack
  • no-op
  • UTF-8
  • JSON
  • YAML

% end main

Interface

Codec

  • encode(obj)

    Encode the object to a bytestream.

  • decode(bytes)

    Decode the given bytes to a single object.

  • feed(bytes, final=False)

    Data stream. Returns an array of objects.

    This method only exists when a sequence of encoded objects can be streamed, i.e. contains built-in message boundaries.

    if @final is True, raise an exception if there is an incomplete object in the buffer after this call.

  • getstate(), setstate(*args)

    A streaming decoder may store partially-decoded state (unprocessed buffer) here.

The list of accepted objects is implementation dependent.

Extension

Extension types vary by whether they carry binary data as in (msgpack), or objects (as in cbor).

  • binary (classvar): True if msgpack-style, False if cbor-style

  • encoder(cls, key, fn)

    Encode an object obj of type type. fn(codec, obj) must return a bytestring / an encodeable object. If the registration key is None the function must return a tuple with the key as first element.

  • decoder(key, fn)

    Add a decoder (key, data) to an object. fn(codec, data) is called with a bytestring / a decoded object, and returns whatever has been encoded.

Extensions get the codec as their first argument. They can use it to store data, e.g. references. The extension object is available as codec.ext.

Metadata

Release files for moat-lib-codec 0.4.21

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for moat-lib-codec 0.4.21
File Size Uploaded
moat_lib_codec-0.4.21.tar.gz 22.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for moat-lib-codec 0.4.21
File Interpreter ABI Platform
moat_lib_codec-0.4.21-py3-none-any.whl Python 3 none any Details

Total release size: 48.0 kB

Release files / moat_lib_codec-0.4.21.tar.gz

Download URL moat_lib_codec-0.4.21.tar.gz
Size 22.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a28171397038ebf05ea8e89e856fde9ef94084c23bbbf09282095f6194674386
BLAKE2b-256 checksum
How to use checksums
a76dd78540d5b4ccd045662dbfdb5061311efa49de324ab70172dbc8f59c7db0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / moat_lib_codec-0.4.21-py3-none-any.whl

Download URL moat_lib_codec-0.4.21-py3-none-any.whl
Size 25.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
171ec845256ce366bbb9cbf6bcbe0fca23939bf834d0c9f72b85654ea2fb9bcc
BLAKE2b-256 checksum
How to use checksums
f0659ece71c72db4b54d35d8f3cd19cdef42bd7718e6ee60cb954eb9b7a3f22f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release history Release notifications | RSS feed

This release

0.4.21 This release

2 release files

0.4.18

2 release files

0.4.16

2 release files

0.4.14

2 release files

0.4.10

2 release files

0.4.9

2 release files

0.4.8

2 release files

0.4.7

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page