pub trait Write {
// Required method
fn write_str(&mut self, s: &str) -> Result<(), Error>;
// Provided methods
fn write_char(&mut self, c: char) -> Result<(), Error> { ... }
fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error> { ... }
}
Expand description
A trait for writing or formatting into Unicode-accepting buffers or streams.
This trait only accepts UTF-8–encoded data and is not flushable. If you only
want to accept Unicode and you don’t need flushing, you should implement this trait;
otherwise you should implement std::io::Write
.
Required Methods§
1.0.0 · sourcefn write_str(&mut self, s: &str) -> Result<(), Error>
fn write_str(&mut self, s: &str) -> Result<(), Error>
Writes a string slice into this writer, returning whether the write succeeded.
This method can only succeed if the entire string slice was successfully written, and this method will not return until all data has been written or an error occurs.
§Errors
This function will return an instance of std::fmt::Error
on error.
The purpose of that error is to abort the formatting operation when the underlying destination encounters some error preventing it from accepting more text; in particular, it does not communicate any information about what error occurred. It should generally be propagated rather than handled, at least when implementing formatting traits.