Expand description
FlatStruct trait + slot header for zero-copy same-host pub/sub.
Crate zerodds-flatdata. Safety classification: STANDARD.
Spec: docs/specs/zerodds-flatdata-1.0.md.
§Safety rationale
This crate implements an unsafe trait FlatStruct whose
guarantees (Copy + repr(C) + ’static + no pointers/Vec/String) the
implementer assures via unsafe impl. The as_bytes /
from_bytes_unchecked helpers are then safe by layout — we
localize the unsafe island here instead of scattering it into
the DataWriter path.
Structs§
- Flat
Reader - Reads FlatStruct samples directly from SHM slots.
- Flat
Sample Ref - Reference sample that holds its source slot for the duration of its
lifetime and sets this reader’s bit on
Drop(releasing the slot for recycling). Spec §9.2/§9.3. Returned byFlatReader::read_ref. - Flat
Slot - Loaned slot. The caller sets the sample via
write()and then callscommit(). Dropping without a commit discards the loan. - Flat
Writer - Writes FlatStruct samples directly into SHM slots — without CDR encoding.
- InMemory
Slot Allocator - In-memory slot allocator. Provides the same
SlotBackendinterface as the POSIX mmap backend (posix.rs), but lives on the process heap — single-process pub/sub and test setups without an mmap dep. - Posix
Slot Allocator - POSIX mmap slot allocator. An owner process creates the segment;
consumer processes attach via
attach. - ShmLocator
- SHM locator: all the data a same-host reader needs to attach to a writer SHM segment.
- Slot
Handle - Slot identification: (segment_id, slot_index).
- Slot
Header - Slot header — set by the writer in
commit_slotand interpreted by the reader inread_flat.
Enums§
- Locator
Error - Error during encode/decode.
- Posix
Slot Error - Error while setting up the POSIX segment.
- Slot
Error - Error during slot management.
Constants§
- SLOT_
HEADER_ SIZE - Size of the slot header in bytes.
Traits§
- Flat
Struct - Marker trait for FlatData-capable types.
- Slot
Backend - Backend trait for the SHM slot allocator.
Functions§
- fnv1a_
32 - FNV-1a hash of the hostname (32-bit). Set by the writer during discovery; the reader checks it against its own.
- is_
same_ host - Same-host match helper. The caller passes (local hostname, local uid)
and a received
ShmLocator; returnstruewhen both match — i.e. we can mmap the segment.
Type Aliases§
- Reader
Mask - Bitmap (32 bit) — one bit per reader slot. Bit set = reader has read. The slot becomes reservable again when all active reader bits are set, or the timeout has elapsed.