pub trait Writeable {
// Provided methods
fn write_to<W: Write + ?Sized>(&self, sink: &mut W) -> Result { ... }
fn write_to_parts<S: PartsWrite + ?Sized>(&self, sink: &mut S) -> Result { ... }
fn writeable_length_hint(&self) -> LengthHint { ... }
fn writeable_borrow(&self) -> Option<&str> { ... }
}Expand description
Writeable is an alternative to std::fmt::Display with the addition of a length function.
Provided Methods§
Sourcefn write_to<W: Write + ?Sized>(&self, sink: &mut W) -> Result
fn write_to<W: Write + ?Sized>(&self, sink: &mut W) -> Result
Writes a string to the given sink. Errors from the sink are bubbled up.
The default implementation delegates to write_to_parts, and discards any
Part annotations.
Sourcefn write_to_parts<S: PartsWrite + ?Sized>(&self, sink: &mut S) -> Result
fn write_to_parts<S: PartsWrite + ?Sized>(&self, sink: &mut S) -> Result
Write bytes and Part annotations to the given sink. Errors from the
sink are bubbled up. The default implementation delegates to write_to,
and doesn’t produce any Part annotations.
Sourcefn writeable_length_hint(&self) -> LengthHint
fn writeable_length_hint(&self) -> LengthHint
Returns a hint for the number of UTF-8 bytes that will be written to the sink.
Override this method if it can be computed quickly.
Sourcefn writeable_borrow(&self) -> Option<&str>
fn writeable_borrow(&self) -> Option<&str>
Returns a &str that matches the output of write_to, if possible.
This method is used to avoid materializing a String in write_to_string.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.