pub struct BufferedWriter { /* private fields */ }Expand description
A simple in-memory buffered writer.
Accumulates output and allows flushing to a target.
Implementations§
Source§impl BufferedWriter
impl BufferedWriter
Sourcepub fn new(flush_threshold: usize) -> Self
pub fn new(flush_threshold: usize) -> Self
Create a new buffered writer with a given flush threshold.
Sourcepub fn default_threshold() -> Self
pub fn default_threshold() -> Self
Create a buffered writer with default threshold (4 KiB).
Sourcepub fn write_bytes(&mut self, data: &[u8])
pub fn write_bytes(&mut self, data: &[u8])
Write bytes to the buffer.
Auto-flushes (clears the buffer) if the threshold is exceeded.
Sourcepub fn buffered_len(&self) -> usize
pub fn buffered_len(&self) -> usize
Get the number of buffered (unflushed) bytes.
Sourcepub fn total_written(&self) -> usize
pub fn total_written(&self) -> usize
Get the total number of bytes written (including flushed).
Auto Trait Implementations§
impl Freeze for BufferedWriter
impl RefUnwindSafe for BufferedWriter
impl Send for BufferedWriter
impl Sync for BufferedWriter
impl Unpin for BufferedWriter
impl UnsafeUnpin for BufferedWriter
impl UnwindSafe for BufferedWriter
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