Expand description
SampleBytes — zero-copy byte container for reader-path samples.
Spec: docs/specs/zerodds-zero-copy-1.0.md §6 Wave 2.
§Background
UserSample::Alive::payload was historically a Vec<u8>. That forced
strip_user_encap to cut off the encap-header offset via
payload[off..].to_vec() — one heap alloc + copy per alive sample.
SampleBytes replaces that Vec with an Arc<[u8]> + range. Strip
operations become pure index arithmetic (Arc::clone is a refcount
bump, not a copy). Heap allocs are eliminated on the hot path.
§API
SampleBytes::from_vec— heap-Vec input (backward compat).SampleBytes::from_arc_slice— Arc + range (zero-copy path).SampleBytes::as_slice— slice read without copy.SampleBytes::to_vec— materialization at an FFI boundary.SampleBytes::len/is_empty— standard container API.Cloneis O(1) — just an Arc refcount bump.
Structs§
- Sample
Bytes - Refcounted byte container for reader-path samples.