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.2.0.tar.gz
(10.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.2.0-py3-none-any.whl
(10.6 kB
view details)
File details
Details for the file cmodel-0.2.0.tar.gz.
File metadata
- Download URL: cmodel-0.2.0.tar.gz
- Upload date:
- Size: 10.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 |
85c328e7e1df18ddacdc7161d33bea2a60cba478cc3c7f0fce58ab577a531b98
|
|
| MD5 |
2b4692b65c70567f2c510a9ff5be40df
|
|
| BLAKE2b-256 |
ec654060774f8f39b07ab8019c436c887630e0c441c159fcebc019dbb3a669f0
|
File details
Details for the file cmodel-0.2.0-py3-none-any.whl.
File metadata
- Download URL: cmodel-0.2.0-py3-none-any.whl
- Upload date:
- Size: 10.6 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 |
954d1054e41d355db0eec51ecd053c439076a64a495291af842aaeb84ba91337
|
|
| MD5 |
07a7b5fed4166fc5e95445265609b64b
|
|
| BLAKE2b-256 |
08971d878712e5a0477a4ceadcd078184ae57d856d69c976631e2ff4bc8cea12
|