Trait Writeable
trait Writeable
Writeable is an alternative to std::fmt::Display with the addition of a length function.
Provided Methods
fn write_to<W: fmt::Write + ?Sized>(self: &Self, sink: &mut W) -> ResultWrites a string to the given sink. Errors from the sink are bubbled up. The default implementation delegates to
write_to_parts, and discards anyPartannotations.fn write_to_parts<S: PartsWrite + ?Sized>(self: &Self, sink: &mut S) -> ResultWrite bytes and
Partannotations to the given sink. Errors from the sink are bubbled up. The default implementation delegates towrite_to, and doesn't produce anyPartannotations.fn writeable_length_hint(self: &Self) -> LengthHintReturns 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.
fn write_to_string(self: &Self) -> Cow<'_, str>Creates a new
Stringwith the data from thisWriteable. LikeToString, but smaller and faster.The default impl allocates an owned
String. However, if it is possible to return a borrowed string, overwrite this method to return aCow::Borrowed.To remove the
Cowwrapper, call.into_owned()or.as_str()as appropriate.Examples
Inspect a
Writeablebefore writing it to the sink:use ; use Writeable;Convert the
Writeableinto a fully ownedString:use Writeable;
Implementors
impl Writeable for u128impl<'a, T: ?Sized + Writeable + Writeable> Writeable for Arc<T>impl Writeable for i64impl Writeable for charimpl<T: Writeable + ?Sized> Writeable for WithPart<T>impl Writeable for u64impl Writeable for Stringimpl<'a, T: ?Sized + Writeable + Writeable> Writeable for Rc<T>impl Writeable for i32impl Writeable for u32impl<T: TryWriteable> Writeable for LossyWrap<T>impl Writeable for strimpl<'a, T: ?Sized + Writeable + Writeable> Writeable for Box<T>impl Writeable for i16impl Writeable for isizeimpl Writeable for u16impl Writeable for usizeimpl<'a, T: ?Sized + Writeable + alloc::borrow::ToOwned> Writeable for Cow<'a, T>impl Writeable for i8impl<T> Writeable for TryWriteableInfallibleAsWriteable<T>impl Writeable for i128impl Writeable for u8impl<T: Writeable + ?Sized> Writeable for &T