Model C structs with Pydantic
Project description
CModel
Model C structs with Pydantic
cmodel lets you describe C-compatible binary layouts with normal Pydantic models.
You keep Pydantic's validation and nested models, and gain a simple way to pack and
unpack structs from binary buffers.
Quick start
from io import BytesIO
from cmodel import CModel
from cmodel.types import Int
class Point(CModel):
x: Int
y: Int
buf = BytesIO()
Point(x=3, y=7).c_pack(buf)
buf.seek(0)
point = Point.c_unpack(buf)
assert point == Point(x=3, y=7)
assert buf.getvalue() == b"\x03\x00\x00\x00\x07\x00\x00\x00"
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
cmodel-0.4.0.tar.gz
(11.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
cmodel-0.4.0-py3-none-any.whl
(11.8 kB
view details)
File details
Details for the file cmodel-0.4.0.tar.gz.
File metadata
- Download URL: cmodel-0.4.0.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b125c970aaad52f9f8ab27fc1a888015f47b2414003038ad35ee7dc3f1257a23
|
|
| MD5 |
da1550ac2c37dd12d03e9abdf3c676cf
|
|
| BLAKE2b-256 |
ef37093f6df507916f1eac1100cb068f59cfcee9e072669d3b7572a9211d352b
|
File details
Details for the file cmodel-0.4.0-py3-none-any.whl.
File metadata
- Download URL: cmodel-0.4.0-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52a2ac6a726fe61a20ca22b52f99b2cec82c4b20d6f97bf1362e40da9865865e
|
|
| MD5 |
2dc95dadb53eb2d3d0e7c2c93fc107a2
|
|
| BLAKE2b-256 |
ebb28cbb94a15b0732cd661329c63332b0e7ed2b8dd70c7a1e7c8ede5d9468e4
|