Dataclass-Like Serialization Helpers for More Complex Data-Types
Project description
PyStructs
Dataclass-Like Serialization Helpers for More Complex Data-Types
This library allows for easy encoding/decoding of standardized struct-like objects. However, it's designed to avoid any dynamic parsing or encoding beyond a basic structure. Dynamic behavior is intentionally excluded and is best left to standard code to reduce the amount of magic involved, and to make for a simpler and more understandable codebase.
Installation
pip install pystructs3
Examples
from pystructs import *
@struct
class A:
x: Int16
y: Int32
ip: Ipv4
data: SizedBytes[16]
ctx = Context()
a = A(69, 420, '1.2.3.4', b'example message')
print(a)
print(a.x)
raw = a.encode(ctx)
print(raw)
ctx.reset()
a2 = A.decode(ctx, raw)
print(a2)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pystructs3-0.0.6.tar.gz
(11.8 kB
view details)
File details
Details for the file pystructs3-0.0.6.tar.gz
.
File metadata
- Download URL: pystructs3-0.0.6.tar.gz
- Upload date:
- Size: 11.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4440a8f79ecea630d7ae300756a7aa2d8ac298778ac26465d96581d2d65796ac |
|
MD5 | 72b9ad46866116ce50abb3a7f934b02d |
|
BLAKE2b-256 | 2b4751f3a0f2d0e1761e652641d053ad7dec1ba3dee3a4209454d64a59f169ef |