Skip to main content

Python bindings for the robolib datapod wire-contract library

Project description

datapod

Rust/C/Python datapod wire contract for robotics data types and POD-oriented containers.

The crate exposes:

  • Rust DataPod implementations and borrowed Archive/View/Owned APIs.
  • A C ABI with owned handles, generic wire helpers, borrowed DatapodArchiveFrame, and typed archive views.
  • Python bindings with generic wire helpers and declarative schema decorators, including fixed-width annotation markers such as datapod.u16, plus ArchiveFrame/memoryview payload access.

Zero-copy model

Use Archive/View for the fast path:

#[datapod::datapod(name = "robolibs.camera_frame.v1")]
pub struct CameraFrame {
    pub width: u32,
    pub height: u32,
    pub encoding: u32,
    #[dp(bytes)]
    pub data: Vec<u8>,
}

let camera = CameraFrame {
    width: 640,
    height: 480,
    encoding: 11,
    data: frame_bytes,
};

camera.archive(|archive| {
    let _view = CameraFrame::view_archive(archive)?;
    publisher.publish_archive(archive)
})?;

let msg = camera.to_wire_message(); // owned/copying convenience path

For custom Rust types, #[datapod(name = "...")] sets the same canonical schema name model used by C/Python runtime schemas. The macro emits CANONICAL_NAME, TYPE_HASH, register_schema, to_wire_message, archive, segmented_archive, view_archive, and from_archive helpers for the type. The older with_wire_frame, view_from_wire_frame, and from_wire_frame names remain as compatibility aliases.

ArchiveFrame/WireFrame borrows header and payload separately and does not allocate a joined payload buffer. OwnedWireMessage/WireMessage { bytes: Vec<u8> } remains the owned convenience path for files, tests, and transports that require contiguous bytes; it is not the performance path.

C uses DatapodArchiveFrame, generic datapod_archive_split(...) / datapod_archive_to_message(...), and typed archive helpers for opaque owned handles such as datapod_matrix_archive(...), datapod_matrix_view_from_archive(...), and datapod_matrix_from_archive(...). Python uses obj.archive(), datapod.view_archive(...), and typed view_archive(...) helpers that expose payloads as memoryview.

Wire format policy

See docs/WIRE_FORMAT.md for the current datapod-wire-v1/le format, validation rules, and C/Python borrowed-view lifetime rules.

Fallible owned container APIs

Rust byte-backed containers keep the historical ergonomic methods (push, pop, get, insert, etc.) as panic-on-invalid convenience wrappers, but the production path is the matching try_* API. Examples include try_push, try_pop, try_get, try_set, try_insert, try_push_back, try_push_front, and try_from_bytes. These fallible methods validate the current owned value before mutation, use checked wire-size arithmetic, and preserve no-mutate-on-error behavior for malformed owned buffers.

Build and test

Use the Makefile lanes:

nix develop --command make test
nix develop --command make bench
nix develop --command make bind
nix develop --command make test-bindings

make bench runs Rust, C, and Python owned-vs-borrowed payload benchmarks and prints copied bytes per operation.

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

robolib_datapod-0.4.1.tar.gz (306.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

robolib_datapod-0.4.1-cp39-abi3-manylinux_2_34_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.34+ x86-64

File details

Details for the file robolib_datapod-0.4.1.tar.gz.

File metadata

  • Download URL: robolib_datapod-0.4.1.tar.gz
  • Upload date:
  • Size: 306.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.11.5

File hashes

Hashes for robolib_datapod-0.4.1.tar.gz
Algorithm Hash digest
SHA256 9d2b0a79a910d1f9c5b29613c13adf7d101dfa7ee6393a56f25c290eafe742e2
MD5 6fe1b650df69869732e2a1ae67a0baff
BLAKE2b-256 13d049504ecb1849e6c6f49e367adccf2d7aa3ae803355001feac927e6e26807

See more details on using hashes here.

File details

Details for the file robolib_datapod-0.4.1-cp39-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for robolib_datapod-0.4.1-cp39-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 dd4e6389ee5a6cd21349bbffba7dfcd8db735002f436b73012ab69aa85067b81
MD5 5b57bfd3c873b09ea4d9ddbe2959c655
BLAKE2b-256 d3b698e17ca0340952aff0e356b31e45aee7fbf300c08c1dbba2d6abdd43614e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page