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.1.0.tar.gz
(9.3 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
File details
Details for the file cmodel-0.1.0.tar.gz.
File metadata
- Download URL: cmodel-0.1.0.tar.gz
- Upload date:
- Size: 9.3 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 |
3463b6dc801c0744fb974220f6c75da16a4784fc0d328f317afbad8d38557e13
|
|
| MD5 |
d9694520a78581b10e10e677f96b4dc5
|
|
| BLAKE2b-256 |
70f45eebad2e3ca0814a63b505111a6ea5ad96ec90dd58cc550746dc3c5e634b
|
File details
Details for the file cmodel-0.1.0-py3-none-any.whl.
File metadata
- Download URL: cmodel-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.5 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 |
6c708d518886d356ad2ceb1105d8a653146913d4075fcb058b3c47bafdc556c1
|
|
| MD5 |
5fe2f2788184c29c0903550132597a31
|
|
| BLAKE2b-256 |
c2d1948b66905c491fc0c6e4a2436dea2a4da7368f822c0d0cb36b7ef2bae7ca
|