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, cstring, u32
from databind.core import datamodel, field
@datamodel
class RiffChunk:
""" RIFF-WAVE chunk header. """
chunk_id: cstring(4) = field(default=b'RIFF')
chunk_size: u32
riff_type: cstring(4) = field(default=b'WAVE')
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.1.0.tar.gz
(3.8 kB
view hashes)
Built Distribution
Close
Hashes for databind.binary-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54ef81a65d02ff0bbe43024ea3c35317ff18226d617357df00d8c7e69dbc5f57 |
|
MD5 | 8becc64278ec133dd20d090ff05a6e52 |
|
BLAKE2b-256 | f6e76734cf707b6d2d39312c18d5a71336e678a2bce96731df4691ae584356a1 |