Bind object-oriented data models to binary data encoded with the struct module.
Project description
databind.binary
Databind is a library inspired by Jackson-databind to describe and bind data models for
object-oriented programming. The databind.binary
package implements conversion of data
models between Python and binary format (using the struct
module).
Todo
- Support (efficient) unpacking of nested structs
Quickstart
from databind.binary import to_bytes, calc_size, cstr, u32
from databind.core import datamodel, field
@datamodel
class RiffChunk:
""" RIFF-WAVE chunk header. """
chunk_id: cstr = field(default=b'RIFF', metadata={'size': 4})
chunk_size: u32
riff_type: cstr = field(default=b'WAVE', metadata={'size': 4})
assert calc_size(RiffChunk) == 12
assert to_bytes(RiffChunk(chunk_size=16442)) == b'RIFF:@\x00\x00WAVE'
Copyright © 2020 – Niklas Rosenstein
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
databind.binary-0.2.0.tar.gz
(5.2 kB
view hashes)
Built Distribution
Close
Hashes for databind.binary-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 136f481ee2283c78fcba5111f3ad28a42963ec5a002b96aeeb3530200437c2f8 |
|
MD5 | 17f1bfb5ece4c79b9e501a7681d1d88d |
|
BLAKE2b-256 | 88b6603a889a45a9c6e8ba090b68ee3278ca620d80e4ae61862d80aebe9ea327 |