pub trait Write: IoBase {
// Required methods
fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error>;
fn flush(&mut self) -> Result<(), Self::Error>;
// Provided method
fn write_all(&mut self, buf: &[u8]) -> Result<(), Self::Error> { ... }
}Expand description
The Write trait allows for writing bytes into the sink.
It is based on the std::io::Write trait.
Required Methods§
Sourcefn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error>
fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error>
Write a buffer into this writer, returning how many bytes were written.
§Errors
Each call to write may generate an I/O error indicating that the operation could not be completed. If an error is returned then no bytes in the buffer were written to this writer. It is not considered an error if the entire buffer could not be written to this writer.
Provided Methods§
Sourcefn write_all(&mut self, buf: &[u8]) -> Result<(), Self::Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Self::Error>
Attempts to write an entire buffer into this writer.
This method will continuously call write until there is no more data to be written or an error is returned.
Errors for which IoError::is_interrupted method returns true are being skipped. This method will not return
until the entire buffer has been successfully written or such an error occurs.
If write returns 0 before the entire buffer has been written this method will return an error instantiated by
a call to IoError::new_write_zero_error.
§Errors
This function will return the first error for which IoError::is_interrupted method returns false that write
returns.
Implementors§
impl<IO: ReadWriteSeek, TP: TimeProvider, OCC> Write for File<'_, IO, TP, OCC>
impl<T: Write> Write for StdIoWrapper<T>
std only.