BufferGroup

Struct BufferGroup 

Source
pub struct BufferGroup {
    pub group_id: u16,
    pub buffer_count: u32,
    pub buffer_size: u32,
    /* private fields */
}
Expand description

Buffer selection group for managing provided buffers.

Allows the kernel to select buffers from a pre-registered pool, enabling zero-copy operations and reducing buffer management overhead.

Fields§

§group_id: u16

Group ID for this buffer set

§buffer_count: u32

Number of buffers in the group

§buffer_size: u32

Size of each buffer in bytes

Implementations§

Source§

impl BufferGroup

Source

pub fn new(group_id: u16, buffer_count: u32, buffer_size: u32) -> Result<Self>

Create a new buffer group with the specified parameters.

§Arguments
  • group_id - Unique identifier for this buffer group
  • buffer_count - Number of buffers to allocate
  • buffer_size - Size of each buffer in bytes
§Errors

Returns an error if buffer allocation fails or parameters are invalid.

§Examples
use safer_ring::advanced::BufferGroup;

let group = BufferGroup::new(1, 100, 4096)?;
Source

pub fn get_buffer(&mut self) -> Option<u16>

Get the next available buffer index.

Returns None if no buffers are available.

Source

pub fn return_buffer(&mut self, buffer_id: u16)

Return a buffer to the available pool.

§Arguments
  • buffer_id - The buffer index to return
§Panics

Panics in debug mode if buffer_id is invalid.

Source

pub fn available_count(&self) -> usize

Get the number of available buffers.

Source

pub fn has_available(&self) -> bool

Check if any buffers are available.

Source

pub fn utilization(&self) -> f64

Get the utilization ratio (0.0 to 1.0).

Returns the fraction of buffers currently in use.

Trait Implementations§

Source§

impl Debug for BufferGroup

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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.