Writeable

Trait Writeable 

Source
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§

Source

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.

Source

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.

Source

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.

Source

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.

Implementations on Foreign Types§

Source§

impl Writeable for char

Source§

impl Writeable for i8

Source§

impl Writeable for i16

Source§

impl Writeable for i32

Source§

impl Writeable for i64

Source§

impl Writeable for i128

Source§

impl Writeable for isize

Source§

impl Writeable for str

Source§

impl Writeable for u8

Source§

impl Writeable for u16

Source§

impl Writeable for u32

Source§

impl Writeable for u64

Source§

impl Writeable for u128

Source§

impl Writeable for usize

Source§

impl<T: Writeable + ?Sized> Writeable for &T

Implementors§