pub trait Write { // Required method fnwrite_str(&mut self, s: &str) ->Result<(),Error>; // Provided methods fnwrite_char(&mut self, c:char) ->Result<(),Error> { ... } fnwrite_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 notflushable. If you onlywant to accept Unicode and you don’t need flushing, you should implement this trait;otherwise you should implementstd::io::Write.
Required Methods§
1.0.0 ·Sourcefnwrite_str(&mut self, s: &str) ->Result<(),Error>
fnwrite_str(&mut self, s: &str) ->Result<(),Error>
Writes a string slice into this writer, returning whether the writesucceeded.
This method can only succeed if the entire string slice was successfullywritten, and this method will not return until all data has beenwritten or an error occurs.
§Errors
This function will return an instance ofstd::fmt::Error on error.
The purpose of that error is to abort the formatting operation when the underlyingdestination encounters some error preventing it from accepting more text;in particular, it does not communicate any information aboutwhat error occurred.It should generally be propagated rather than handled, at least when implementingformatting traits.
§Examples
Provided Methods§
1.1.0 ·Sourcefnwrite_char(&mut self, c:char) ->Result<(),Error>
fnwrite_char(&mut self, c:char) ->Result<(),Error>
Writes achar into this writer, returning whether the write succeeded.
A singlechar may be encoded as more than one byte.This method can only succeed if the entire byte sequence was successfullywritten, and this method will not return until all data has beenwritten or an error occurs.
§Errors
This function will return an instance ofError on error.