pub struct BytePool { /* private fields */ }Expand description
Thread-safe pool of reusable byte buffers.
Implementations§
Source§impl BytePool
impl BytePool
Sourcepub fn before_cap(&self) -> usize
pub fn before_cap(&self) -> usize
Pool’s default leading head-room.
Sourcepub fn new(
before_cap: usize,
size: usize,
after_cap: usize,
initial: usize,
max_pooled: usize,
) -> Self
pub fn new( before_cap: usize, size: usize, after_cap: usize, initial: usize, max_pooled: usize, ) -> Self
Create a new pool.
before_cap: header space before main datasize: main data capacityafter_cap: trailer space after main datainitial: pre-allocated buffer countmax_pooled: maximum buffers to keep in pool
Sourcepub fn allocate(&self, size: Option<usize>) -> DynamicByteBuffer
pub fn allocate(&self, size: Option<usize>) -> DynamicByteBuffer
Get a buffer from pool or allocate new one.
size: optional size limit (must be <= pool’s size), None for full size
Returns a DynamicByteBuffer that auto-returns to pool on drop.
Sourcepub fn allocate_for_recv(&self) -> DynamicByteBuffer
pub fn allocate_for_recv(&self) -> DynamicByteBuffer
Allocate a buffer sized for receiving raw packets from the network. Uses the maximum available active view (size + after_cap) to accommodate on-wire packets that are larger than the user-data MTU due to protocol overhead. The before_cap headroom is preserved for subsequent send-path expand_start calls.
pub fn allocate_precise( &self, size: usize, before_cap: usize, after_cap: usize, ) -> DynamicByteBuffer
pub fn allocate_precise_from_slice_with_capacity( &self, data: &[u8], before_cap: usize, after_cap: usize, ) -> DynamicByteBuffer
pub fn allocate_precise_from_array_with_capacity<const N: usize>( &self, arr: &[u8; N], before_cap: usize, after_cap: usize, ) -> DynamicByteBuffer
Auto Trait Implementations§
impl Freeze for BytePool
impl RefUnwindSafe for BytePool
impl Send for BytePool
impl Sync for BytePool
impl Unpin for BytePool
impl UnsafeUnpin for BytePool
impl UnwindSafe for BytePool
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