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: u16Group ID for this buffer set
buffer_count: u32Number of buffers in the group
buffer_size: u32Size of each buffer in bytes
Implementations§
Source§impl BufferGroup
impl BufferGroup
Sourcepub fn new(group_id: u16, buffer_count: u32, buffer_size: u32) -> Result<Self>
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 groupbuffer_count- Number of buffers to allocatebuffer_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)?;Sourcepub fn get_buffer(&mut self) -> Option<u16>
pub fn get_buffer(&mut self) -> Option<u16>
Get the next available buffer index.
Returns None if no buffers are available.
Sourcepub fn return_buffer(&mut self, buffer_id: u16)
pub fn return_buffer(&mut self, buffer_id: u16)
Sourcepub fn available_count(&self) -> usize
pub fn available_count(&self) -> usize
Get the number of available buffers.
Sourcepub fn has_available(&self) -> bool
pub fn has_available(&self) -> bool
Check if any buffers are available.
Sourcepub fn utilization(&self) -> f64
pub fn utilization(&self) -> f64
Get the utilization ratio (0.0 to 1.0).
Returns the fraction of buffers currently in use.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BufferGroup
impl RefUnwindSafe for BufferGroup
impl Send for BufferGroup
impl Sync for BufferGroup
impl Unpin for BufferGroup
impl UnwindSafe for BufferGroup
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more