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.22

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.22
File Size Uploaded
moat_lib_codec-0.4.22.tar.gz 22.3 kB Details

Built distribution (wheel)

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

Total release size: 48.2 kB

Release files / moat_lib_codec-0.4.22.tar.gz

Download URL moat_lib_codec-0.4.22.tar.gz
Size 22.3 kB
Tags Source
SHA-256 checksum
How to use checksums
6626db629898319e8a6cd16804d236850e911207aa756600e6a734ef6380e7bd
BLAKE2b-256 checksum
How to use checksums
2663413eb8be2098da33ae21cc95a33951019105e87a26fd36553dbeb835b90c
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.22-py3-none-any.whl

Download URL moat_lib_codec-0.4.22-py3-none-any.whl
Size 25.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
67595e8457ca14e6a75961cf68cb94df6b746d5a345a68a14cbfd25a2b68e3c3
BLAKE2b-256 checksum
How to use checksums
669c22fd8b0e4d69efb149a65d612ab219be753488fee8830c683d0eaf2ece98
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.22 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