pub struct Writer<'a> { /* private fields */ }
Expand description
Writer implements buffering for an std::io::Write object. If an error occurs writing to a Writer, no more data will be accepted and all subsequent writes, and flush, will return the error. After all data has been written, the client should call the flush method to guarantee all data has been forwarded to the underlying std::io::Write.
Consider using native Rust std::io::BufWriter.
Implementations§
Source§impl<'a> Writer<'a>
impl<'a> Writer<'a>
Sourcepub fn new(w: &'a mut dyn Write) -> Self
pub fn new(w: &'a mut dyn Write) -> Self
new returns a new Writer whose buffer has the default size.
Sourcepub fn new_size(w: &'a mut dyn Write, size: usize) -> Self
pub fn new_size(w: &'a mut dyn Write, size: usize) -> Self
new_size returns a new Writer whose buffer has at least the specified size.
Sourcepub fn reset(&mut self, w: &'a mut dyn Write)
pub fn reset(&mut self, w: &'a mut dyn Write)
reset discards any unflushed buffered data, clears any error, and resets b to write its output to w.
pub fn available(&self) -> usize
Sourcepub fn write_byte(&mut self, c: u8) -> Result<()>
pub fn write_byte(&mut self, c: u8) -> Result<()>
write_byte writes a single byte.
Sourcepub fn write_string(&mut self, s: &str) -> Result<usize>
pub fn write_string(&mut self, s: &str) -> Result<usize>
write_string writes a string. It returns the number of bytes written.
Trait Implementations§
Source§impl Write for Writer<'_>
impl Write for Writer<'_>
Source§fn write(&mut self, p: &[u8]) -> Result<usize>
fn write(&mut self, p: &[u8]) -> Result<usize>
Write writes the contents of p into the buffer. It returns the number of bytes written.
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
flush writes any buffered data to the underlying std::io::Write.
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector
)1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored
)