Pythonic implementation of the 'postcard' wire format
Project description
Pohlednice
Pohlednice is a pythonic implementation of the postcard wire format.
Usage
Variable integer:
from pohlednice import I16, I32
I16.to_bytes(400) // a byte iterator
bytes(I16.to_bytes(400)) // transform into bytes
// or chain multiple
chain(I16.to_bytes(3600), I32.to_bytes(55))
// read from a byte iterable
number I16.from_bytes([1])
De/Serialize Structure:
from pohlednice import Struct, U16, String, Option, ByteArray
class ABC(Struct):
a: U16
b: String
c: Option[ByteArray]
payload = bytes(ABC.to_bytes(ABC(40, 'Trollě', None)))
abc = ABC.from_bytes(payload)
De/Serialize Enum:
class Color(Enum):
Red: None
Blue: None
Green: None
Custom: Tuple[U8, U8, U8]
payload = Color.to_bytes(Color.Custom((0xff, 0xf0, 0x0f)))
color = Color.from_bytes(payload)
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
pohlednice-0.2.1.tar.gz
(4.3 kB
view hashes)
Built Distribution
Close
Hashes for pohlednice-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 456d1e2cbfc9399b44d9939f7486dcd16a5fc6f08f73b9828d39f9a9e16cad5d |
|
MD5 | d0c51af7e5b262fbf0a3662caaf5e43c |
|
BLAKE2b-256 | 92c6767bc3b4b2cebcc6769df2130cf0f0872f3f2f0b38454051ddcf9af6b94c |