zerodds-flatdata
Zero-copy same-host pub/sub for the ZeroDDS stack: FlatStruct trait, slot layout per spec, three production SlotBackend implementations (in-memory + POSIX shm/mmap + Iceoryx2 bridge). Safety classification: STANDARD (localized with per-block SAFETY comments around the unsafe trait FlatStruct guarantees).
Spec mapping
| Spec | Section |
|---|---|
| ZeroDDS-flatdata 1.0 | §1 (FlatStruct + derive), §2 (slot layout), §4 (wire path), §5 (lifetime + refcount), §6 (schema versioning), §7 (security), §8/§9 (writer/reader API) |
| ADR-0003 | Three-backend architecture (in-memory / POSIX shm / Iceoryx2) |
What's inside
FlatStructtrait —unsafe traitwithCopy + 'static + Send + Syncand aTYPE_HASHconstant. Guarantees layout stability so thatas_bytes()andfrom_bytes_unchecked()are safe by layout.SlotHeader+ slot layout — 16-byte header (sequence_number,sample_size,reader_mask, reserved) + payload (spec §2).SlotBackendtrait — abstracts the backend; readers/writers are generic.InMemorySlotAllocator— default backend for tests + single-process pub/sub.PosixSlotAllocator(featureposix-mmap, on by default) —shm_open+mmap, cross-process same-host. Owner/consumer model with a flink file.Iceoryx2Publisher<T>/Iceoryx2Subscriber<T>(featureiceoryx2-bridge) — separate pub/sub API against Eclipse iceoryx2 v0.8. Maps toloan_slice_uninit+send/receive. Type-hash cross-validation via service-name composition.FlatWriter<T>+FlatSlot<T>— spec §8.1/§8.2:write+loan_slot+commit/ Drop-discard.FlatReader<T>+FlatSampleRef<T>— spec §9.1:readwith type-hash cross-validation (spec §6.1) +last_snre-read suppression.ShmLocator+is_same_host+ FNV-1a helper — discovery vendor-PID helpers.
Layer position
Layer 4 — Core Services. No ZeroDDS crate deps; the only external dep is shared_memory (optional, behind the posix-mmap feature).
Quickstart
use Arc;
use ;
unsafe
let alloc = new;
let writer = new;
let reader = new;
writer.write.unwrap;
let got = reader.read.unwrap.unwrap;
assert_eq!;
Feature flags
| Feature | Default | Purpose |
|---|---|---|
std |
✅ | Standard library + Mutex + threads. |
alloc |
✅ (via std) | Vec/Arc. |
posix-mmap |
✅ | PosixSlotAllocator (POSIX shm_open + mmap). Depends on shared_memory. |
iceoryx2-bridge |
❌ | Iceoryx2 adapter skeleton (bridge to iceoryx2 service). |
Stability
All pub items are stable as of 1.0.0. The unsafe trait FlatStruct is API-stable; implementers must guarantee the layout properties via unsafe impl.
Tests
License
Apache-2.0. See LICENSE.
See also
docs/specs/zerodds-flatdata-1.0.mdzerodds-dcps— DCPS integration (featureflatdata-integration)zerodds-flatdata-derive—#[derive(FlatStruct)]proc-macro