Skip to main content

Module buffer

Module buffer 

Source
Expand description

Zero-copy multimodal buffers — §λ-L-E Fase 11.b.

Bytes that enter the runtime through a network socket, file handle or FFI boundary land directly in a region of Rust- owned memory. The Python layer manipulates SymbolicPtr<T> handles (Arc clones) — never the raw bytes — until the final consumer (transcoder, compressor, sink) asks for a slice.

Three building blocks:

  • BufferKind — content-kind tag (raw, pcm16, mulaw8, jpeg, …). Extensible (unlike the closed catalogues of 11.a); adopters can register new kinds via [BufferKind::register].
  • ZeroCopyBuffer — the primitive. An Arc<[u8]> plus a BufferKind tag. Clone is O(1) (Arc refcount bump); slicing returns another ZeroCopyBuffer that shares the same backing allocation.
  • BufferMut — mutable in-flight builder. Accumulates bytes during ingest then .freeze()s into an immutable ZeroCopyBuffer at end-of-stream.

Pool-backed allocation lives in the sibling pool module.

Re-exports§

pub use self::kind::BufferKind;
pub use self::kind::BufferKindRegistry;
pub use self::pool::BufferPool;
pub use self::pool::BufferPoolSnapshot;
pub use self::pool::PoolClass;

Modules§

kind
BufferKind — content-kind tags for multimodal buffers.
pool
BufferPool — slab allocator for [ZeroCopyBuffer] storage.

Structs§

BufferMut
Mutable append-only builder used while bytes are still arriving. When the ingest stream terminates, call BufferMut::freeze to convert into an immutable ZeroCopyBuffer with a single Arc construction (no copy).
ZeroCopyBuffer
An immutable view over a region of bytes. Cloneable at O(1) — the backing storage is an Arc<[u8]> so clones are refcount bumps.