pub struct BufferPool { /* private fields */ }Expand description
Thread-safe pool of pre-allocated aligned buffers for io_uring fixed-buffer I/O.
Implementations§
Source§impl BufferPool
impl BufferPool
Sourcepub fn new(
requested_buffers: usize,
requested_chunk_size: usize,
alignment: usize,
) -> Result<Self>
pub fn new( requested_buffers: usize, requested_chunk_size: usize, alignment: usize, ) -> Result<Self>
Create a shared buffer pool with cross-thread access.
Sourcepub fn new_local(
requested_buffers: usize,
requested_chunk_size: usize,
alignment: usize,
) -> Result<Self>
pub fn new_local( requested_buffers: usize, requested_chunk_size: usize, alignment: usize, ) -> Result<Self>
Create a thread-local buffer pool (no cross-thread synchronization).
Sourcepub fn chunk_size(&self) -> usize
pub fn chunk_size(&self) -> usize
Returns the size in bytes of each buffer chunk.
Sourcepub fn get_ptr(&self, index: u16) -> Option<*mut u8>
pub fn get_ptr(&self, index: u16) -> Option<*mut u8>
Returns the raw pointer for the buffer at the given index.
Sourcepub fn get_len(&self, index: u16) -> usize
pub fn get_len(&self, index: u16) -> usize
Returns the current data length of the buffer at the given index.
Sourcepub fn set_len(&self, index: u16, len: usize) -> Result<()>
pub fn set_len(&self, index: u16, len: usize) -> Result<()>
Sets the data length of the buffer at the given index.
Sourcepub fn as_io_vecs(&mut self) -> Vec<iovec>
pub fn as_io_vecs(&mut self) -> Vec<iovec>
Build io_uring iovec descriptors from the pool’s buffers.
Sourcepub fn acquire(&self) -> Option<u16>
pub fn acquire(&self) -> Option<u16>
Acquires a free buffer index from the pool, returning None if exhausted.
Sourcepub fn free_count(&self) -> usize
pub fn free_count(&self) -> usize
Returns the number of currently available buffers in the pool.
Trait Implementations§
Source§impl Clone for BufferPool
impl Clone for BufferPool
Source§fn clone(&self) -> BufferPool
fn clone(&self) -> BufferPool
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for BufferPool
impl !RefUnwindSafe for BufferPool
impl Send for BufferPool
impl Sync for BufferPool
impl Unpin for BufferPool
impl UnsafeUnpin for BufferPool
impl !UnwindSafe for BufferPool
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more