pub struct IoBuffer { /* private fields */ }Expand description
A buffered I/O sink that accumulates writes and flushes on demand.
Implementations§
Source§impl IoBuffer
impl IoBuffer
Sourcepub fn new(flush_threshold: usize) -> Self
pub fn new(flush_threshold: usize) -> Self
Create a buffer with the given flush threshold (bytes).
Sourcepub fn write(&mut self, data: &[u8]) -> Vec<u8> ⓘ
pub fn write(&mut self, data: &[u8]) -> Vec<u8> ⓘ
Write bytes to the buffer. Auto-flushes when threshold is exceeded.
Sourcepub fn buffered_bytes(&self) -> usize
pub fn buffered_bytes(&self) -> usize
Current buffer occupancy in bytes.
Sourcepub fn write_count(&self) -> u64
pub fn write_count(&self) -> u64
Number of write calls.
Sourcepub fn flush_count(&self) -> u64
pub fn flush_count(&self) -> u64
Number of flush calls.
Sourcepub fn total_bytes(&self) -> u64
pub fn total_bytes(&self) -> u64
Total bytes written (including not-yet-flushed data).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for IoBuffer
impl RefUnwindSafe for IoBuffer
impl Send for IoBuffer
impl Sync for IoBuffer
impl Unpin for IoBuffer
impl UnsafeUnpin for IoBuffer
impl UnwindSafe for IoBuffer
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