pub struct BufferManager<W: IoWrite> { /* private fields */ }Expand description
Manages buffered writing with automatic flushing and memory limits
Implementations§
Source§impl<W: IoWrite> BufferManager<W>
impl<W: IoWrite> BufferManager<W>
Sourcepub fn new(writer: W, max_buffer_size: usize) -> IoResult<Self>
pub fn new(writer: W, max_buffer_size: usize) -> IoResult<Self>
Create a new buffer manager with default configuration
Sourcepub fn new_with_config(writer: W, config: BufferConfig) -> IoResult<Self>
pub fn new_with_config(writer: W, config: BufferConfig) -> IoResult<Self>
Create a new buffer manager with custom configuration
Sourcepub fn set_flush_callback(&mut self, callback: FlushCallback)
pub fn set_flush_callback(&mut self, callback: FlushCallback)
Set a callback to be called when buffers are flushed
Sourcepub fn write_chunk(&mut self, data: &[u8]) -> IoResult<()>
pub fn write_chunk(&mut self, data: &[u8]) -> IoResult<()>
Write a chunk of data to the buffer
Sourcepub fn flush_current_buffer(&mut self) -> IoResult<()>
pub fn flush_current_buffer(&mut self) -> IoResult<()>
Flush the current buffer to the queue
Sourcepub fn flush_oldest_buffer(&mut self) -> IoResult<()>
pub fn flush_oldest_buffer(&mut self) -> IoResult<()>
Flush the oldest buffer to the writer
Sourcepub fn current_memory_usage(&self) -> usize
pub fn current_memory_usage(&self) -> usize
Get current memory usage in bytes
Sourcepub fn current_buffer_size(&self) -> usize
pub fn current_buffer_size(&self) -> usize
Get current buffer size
Sourcepub fn total_bytes_written(&self) -> usize
pub fn total_bytes_written(&self) -> usize
Get total bytes written so far
Sourcepub fn peak_buffer_size(&self) -> usize
pub fn peak_buffer_size(&self) -> usize
Get peak buffer size reached
Sourcepub fn total_flushes(&self) -> usize
pub fn total_flushes(&self) -> usize
Get total number of flushes performed
Sourcepub fn queued_buffer_count(&self) -> usize
pub fn queued_buffer_count(&self) -> usize
Get number of buffers currently queued
Sourcepub fn is_near_capacity(&self) -> bool
pub fn is_near_capacity(&self) -> bool
Check if buffers are near capacity
Sourcepub fn get_stats(&self) -> BufferStats
pub fn get_stats(&self) -> BufferStats
Get buffer statistics
Trait Implementations§
Auto Trait Implementations§
impl<W> Freeze for BufferManager<W>where
W: Freeze,
impl<W> !RefUnwindSafe for BufferManager<W>
impl<W> Send for BufferManager<W>where
W: Send,
impl<W> Sync for BufferManager<W>where
W: Sync,
impl<W> Unpin for BufferManager<W>where
W: Unpin,
impl<W> !UnwindSafe for BufferManager<W>
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