pub struct CompressionBufferPool { /* private fields */ }Expand description
A pool for compression output buffers to reduce allocations in hot paths. Compression can be expensive, so reusing buffers improves performance.
Implementations§
Source§impl CompressionBufferPool
impl CompressionBufferPool
Sourcepub fn new(max_buffer_size: usize, max_pool_size: usize) -> Self
pub fn new(max_buffer_size: usize, max_pool_size: usize) -> Self
Creates a new compression buffer pool.
Sourcepub fn acquire(&mut self) -> Vec<u8> ⓘ
pub fn acquire(&mut self) -> Vec<u8> ⓘ
Acquires a buffer from the pool or creates a new one. The buffer is cleared and ready to use.
Sourcepub fn release(&mut self, buffer: Vec<u8>)
pub fn release(&mut self, buffer: Vec<u8>)
Returns a buffer to the pool for reuse. Buffers larger than max_buffer_size are not pooled.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CompressionBufferPool
impl RefUnwindSafe for CompressionBufferPool
impl Send for CompressionBufferPool
impl Sync for CompressionBufferPool
impl Unpin for CompressionBufferPool
impl UnwindSafe for CompressionBufferPool
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