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.5.0.tar.gz
(11.6 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.5.0-py3-none-any.whl
(11.8 kB
view details)
File details
Details for the file cmodel-0.5.0.tar.gz.
File metadata
- Download URL: cmodel-0.5.0.tar.gz
- Upload date:
- Size: 11.6 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 |
17f5ff505a2e0f5ede744c44f5d939c71ff3188f342d82a663e7357bc8e80d7f
|
|
| MD5 |
3c5c14c94b308b70e7ffb36109cbb342
|
|
| BLAKE2b-256 |
5f9ed8c62eb437b9d33f1920917fa56e60795f3575094b49c2c2774f87279882
|
File details
Details for the file cmodel-0.5.0-py3-none-any.whl.
File metadata
- Download URL: cmodel-0.5.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 |
36fca9c9278e197b4884bb9347927495733945dd4867a028dc0bd0997c38dc1f
|
|
| MD5 |
25d136f93067f7074dc3284a8f72129e
|
|
| BLAKE2b-256 |
c553a0459985bfe6a534fb47112ca0c1f331e019428a304309d9f9aacb08c577
|