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
objof typetype.fn(codec, obj)must return a bytestring / an encodeable object. If the registration key isNonethe 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)
| File | Size | Uploaded | |
|---|---|---|---|
| moat_lib_codec-0.4.21.tar.gz | 22.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 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
|