Skip to main content

FrameRegion

Struct FrameRegion 

Source
pub struct FrameRegion { /* private fields */ }
Expand description

Concurrent fixed-block region. Multi-producer alloc, multi-consumer free, any-order reclaim.

Implementations§

Source§

impl FrameRegion

Source

pub fn create_anon( block_size: usize, block_count: usize, ) -> Result<Self, RingError>

Anonymous in-process region.

Source

pub fn create( path: impl AsRef<Path>, block_size: usize, block_count: usize, ) -> Result<Self, RingError>

File-backed region; cross-process via the page cache.

Source

pub fn open( path: impl AsRef<Path>, block_size: usize, block_count: usize, ) -> Result<Self, RingError>

Open an existing file-backed region. Validates the header.

Source

pub fn create_from_shm( shm: ShmFile, block_size: usize, block_count: usize, ) -> Result<Self, RingError>

Build a region on a named RAM-resident shared-memory backing.

Source

pub fn open_from_shm( shm: ShmFile, block_size: usize, block_count: usize, ) -> Result<Self, RingError>

Open an existing named ShmFs-backed region (no re-init).

Source

pub fn create_or_open_shm( name: &str, block_size: usize, block_count: usize, ) -> Result<Self, RingError>

Create-or-open a named ShmFs frame region. The first attacher CAS-initialises the layout and publishes the magic; racing attachers spin until it lands, so a late-joining consumer never wipes a region a producer already filled. This is the shared payload region the cross-process offset-frame path needs: the producer create-or-opens it on the first offset send_frame, and every consumer create-or-opens the SAME region on the first offset recv_frame (the descriptor it popped implies the producer already created it).

Source

pub fn create_or_open_file( path: impl AsRef<Path>, block_size: usize, block_count: usize, ) -> Result<Self, RingError>

Create-or-open a file-backed frame region: the file-locale peer of create_or_open_shm, for rings backed by [AdaptiveRing::create] / open.

Source

pub fn block_size(&self) -> usize

Largest payload a block holds.

Source

pub fn block_count(&self) -> usize

Number of blocks.

Source

pub fn alloc(&self) -> Option<u32>

Allocate a block. Free list first, then bump. None when full.

Source

pub fn free(&self, idx: u32)

Return a block to the free list. Any consumer may free any block.

Source

pub fn write_block(&self, idx: u32, payload: &[u8])

Copy payload into block idx. Caller guarantees payload.len() <= block_size.

Source

pub fn read_block_into(&self, idx: u32, len: usize, out: &mut Vec<u8>)

Copy len bytes out of block idx into out (appended).

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.