Skip to main content

FrameRing

Struct FrameRing 

Source
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

Source

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).

Source

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.

Source

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.

Source

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).

Source

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).

Source

pub fn capacity(&self) -> usize

Descriptor slot count (power of 2).

Source

pub fn slot_size(&self) -> usize

Descriptor stride in bytes.

Source

pub fn inline_budget(&self) -> usize

Largest payload stored inline (slot_size - 8).

Source

pub fn region_bytes(&self) -> usize

Byte-region size. Region payloads cap at half this.

Source

pub fn max_payload(&self) -> usize

Largest payload the region accepts (region_bytes / 2).

Source

pub fn approx_len(&self) -> usize

Items waiting in the descriptor ring (desc_head - desc_tail).

Source

pub fn send(&self, payload: &[u8]) -> Result<FrameClass, RingError>

Send a payload, letting the ring pick inline vs region.

Source

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.

Source

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.

Source

pub fn recv(&self) -> Result<Vec<u8>, RingError>

Receive the next payload as a fresh Vec.

Source

pub fn flush(&self) -> Result<(), RingError>

Force any dirty MMF pages to disk (file backing only).

Trait Implementations§

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.