pub struct BufferPool { /* private fields */ }Expand description
A pool of reusable buffers for HTTP response bodies
Implementations§
Source§impl BufferPool
impl BufferPool
Sourcepub fn new(buffer_size: usize, max_pool_size: usize) -> Self
pub fn new(buffer_size: usize, max_pool_size: usize) -> Self
Create a new buffer pool
§Arguments
buffer_size- Initial size of each buffer (e.g., 512KB for typical market data)max_pool_size- Maximum number of buffers to keep in the pool
Sourcepub async fn get(&self) -> Vec<u8> ⓘ
pub async fn get(&self) -> Vec<u8> ⓘ
Get a buffer from the pool, or create a new one if pool is empty
Sourcepub async fn return_buffer(&self, buffer: Vec<u8>)
pub async fn return_buffer(&self, buffer: Vec<u8>)
Return a buffer to the pool
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BufferPool
impl !RefUnwindSafe for BufferPool
impl Send for BufferPool
impl Sync for BufferPool
impl Unpin 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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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