pub struct FrameRing { /* private fields */ }Expand description
Self-describing variable-payload SPSC ring. One producer, one consumer. Carries any payload size: small inline, large via the co-located byte region, the layout chosen per record and recorded in the descriptor.
Implementations§
Source§impl FrameRing
impl FrameRing
Sourcepub fn create_anon(
capacity: usize,
slot_size: usize,
region_bytes: usize,
) -> Result<Self, RingError>
pub fn create_anon( capacity: usize, slot_size: usize, region_bytes: usize, ) -> Result<Self, RingError>
Anonymous in-process frame ring. slot_size is the descriptor
stride (inline budget is slot_size - 8); region_bytes sizes
the spill region (payloads cap at region_bytes / 2).
Sourcepub fn create(
path: impl AsRef<Path>,
capacity: usize,
slot_size: usize,
region_bytes: usize,
) -> Result<Self, RingError>
pub fn create( path: impl AsRef<Path>, capacity: usize, slot_size: usize, region_bytes: usize, ) -> Result<Self, RingError>
File-backed frame ring; cross-process via the OS page cache.
Sourcepub fn open(
path: impl AsRef<Path>,
capacity: usize,
slot_size: usize,
region_bytes: usize,
) -> Result<Self, RingError>
pub fn open( path: impl AsRef<Path>, capacity: usize, slot_size: usize, region_bytes: usize, ) -> Result<Self, RingError>
Open an existing file-backed frame ring. Validates the header.
Sourcepub fn create_from_shm(
shm: ShmFile,
capacity: usize,
slot_size: usize,
region_bytes: usize,
) -> Result<Self, RingError>
pub fn create_from_shm( shm: ShmFile, capacity: usize, slot_size: usize, region_bytes: usize, ) -> Result<Self, RingError>
Build a fresh frame ring on a named RAM-resident shared-memory backing (cross-process, never touches the page cache).
Sourcepub fn open_from_shm(
shm: ShmFile,
capacity: usize,
slot_size: usize,
region_bytes: usize,
) -> Result<Self, RingError>
pub fn open_from_shm( shm: ShmFile, capacity: usize, slot_size: usize, region_bytes: usize, ) -> Result<Self, RingError>
Open an existing named ShmFs-backed frame ring (no re-init).
Sourcepub fn inline_budget(&self) -> usize
pub fn inline_budget(&self) -> usize
Largest payload stored inline (slot_size - 8).
Sourcepub fn region_bytes(&self) -> usize
pub fn region_bytes(&self) -> usize
Byte-region size. Region payloads cap at half this.
Sourcepub fn max_payload(&self) -> usize
pub fn max_payload(&self) -> usize
Largest payload the region accepts (region_bytes / 2).
Sourcepub fn approx_len(&self) -> usize
pub fn approx_len(&self) -> usize
Items waiting in the descriptor ring (desc_head - desc_tail).
Sourcepub fn send(&self, payload: &[u8]) -> Result<FrameClass, RingError>
pub fn send(&self, payload: &[u8]) -> Result<FrameClass, RingError>
Send a payload, letting the ring pick inline vs region.
Sourcepub fn send_as(
&self,
payload: &[u8],
hint: LayoutHint,
) -> Result<FrameClass, RingError>
pub fn send_as( &self, payload: &[u8], hint: LayoutHint, ) -> Result<FrameClass, RingError>
Send a payload with an explicit layout override. Caller is the sole producer.
Sourcepub fn recv_into(&self, out: &mut Vec<u8>) -> Result<FrameClass, RingError>
pub fn recv_into(&self, out: &mut Vec<u8>) -> Result<FrameClass, RingError>
Receive the next payload into out (cleared then filled).
Returns the FrameClass the producer used. Caller is the
sole consumer.