kvarn::prelude

Trait Display

1.0.0 · source
pub trait Display {
    // Required method
    fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>;
}
Expand description

Format trait for an empty format, {}.

Implementing this trait for a type will automatically implement the ToString trait for the type, allowing the usage of the .to_string() method. Prefer implementing the Display trait for a type, rather than ToString.

Display is similar to Debug, but Display is for user-facing output, and so cannot be derived.

For more information on formatters, see the module-level documentation.

§Internationalization

Because a type can only have one Display implementation, it is often preferable to only implement Display when there is a single most “obvious” way that values can be formatted as text. This could mean formatting according to the “invariant” culture and “undefined” locale, or it could mean that the type display is designed for a specific culture/locale, such as developer logs.

If not all values have a justifiably canonical textual format or if you want to support alternative formats not covered by the standard set of possible formatting traits, the most flexible approach is display adapters: methods like str::escape_default or Path::display which create a wrapper implementing Display to output the specific display format.

§Examples

Implementing Display on a type:

use std::fmt;

struct Point {
    x: i32,
    y: i32,
}

impl fmt::Display for Point {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "({}, {})", self.x, self.y)
    }
}

let origin = Point { x: 0, y: 0 };

assert_eq!(format!("The origin is: {origin}"), "The origin is: (0, 0)");

Required Methods§

1.0.0 · source

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter.

§Errors

This function should return Err if, and only if, the provided Formatter returns Err. String formatting is considered an infallible operation; this function only returns a Result because writing to the underlying stream might fail and it must provide a way to propagate the fact that an error has occurred back up the stack.

§Examples
use std::fmt;

struct Position {
    longitude: f32,
    latitude: f32,
}

impl fmt::Display for Position {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "({}, {})", self.longitude, self.latitude)
    }
}

assert_eq!(
    "(1.987, 2.983)",
    format!("{}", Position { longitude: 1.987, latitude: 2.983, }),
);

Implementors§

source§

impl Display for kvarn::encryption::Error

1.7.0 · source§

impl Display for IpAddr

1.0.0 · source§

impl Display for SocketAddr

1.0.0 · source§

impl Display for VarError

1.15.0 · source§

impl Display for std::sync::mpsc::RecvTimeoutError

1.0.0 · source§

impl Display for std::sync::mpsc::TryRecvError

source§

impl Display for log::Level

source§

impl Display for log::LevelFilter

source§

impl Display for Variant

source§

impl Display for BernoulliError

source§

impl Display for WeightedError

source§

impl Display for AsciiChar

1.34.0 · source§

impl Display for Infallible

§

impl Display for ToCompactStringError

1.60.0 · source§

impl Display for ErrorKind

1.0.0 · source§

impl Display for bool

1.0.0 · source§

impl Display for char

1.0.0 · source§

impl Display for f32

1.0.0 · source§

impl Display for f64

1.0.0 · source§

impl Display for i8

1.0.0 · source§

impl Display for i16

1.0.0 · source§

impl Display for i32

1.0.0 · source§

impl Display for i64

1.0.0 · source§

impl Display for i128

1.0.0 · source§

impl Display for isize

source§

impl Display for !

1.0.0 · source§

impl Display for str

1.0.0 · source§

impl Display for u8

1.0.0 · source§

impl Display for u16

1.0.0 · source§

impl Display for u32

1.0.0 · source§

impl Display for u64

1.0.0 · source§

impl Display for u128

1.0.0 · source§

impl Display for usize

source§

impl Display for Id

§

impl Display for OffsetDateTime

source§

impl Display for UnorderedKeyError

1.57.0 · source§

impl Display for alloc::collections::TryReserveError

1.58.0 · source§

impl Display for FromVecWithNulError

1.7.0 · source§

impl Display for IntoStringError

1.0.0 · source§

impl Display for NulError

1.0.0 · source§

impl Display for FromUtf8Error

1.0.0 · source§

impl Display for FromUtf16Error

1.0.0 · source§

impl Display for String

1.65.0 · source§

impl Display for Backtrace

1.0.0 · source§

impl Display for JoinPathsError

source§

impl Display for std::ffi::os_str::Display<'_>

1.26.0 · source§

impl Display for PanicHookInfo<'_>

1.0.0 · source§

impl Display for std::path::Display<'_>

1.7.0 · source§

impl Display for StripPrefixError

1.0.0 · source§

impl Display for ExitStatus

source§

impl Display for ExitStatusError

1.0.0 · source§

impl Display for std::sync::mpsc::RecvError

1.26.0 · source§

impl Display for AccessError

1.8.0 · source§

impl Display for SystemTimeError

source§

impl Display for FixedBitSet

source§

impl Display for CompressError

source§

impl Display for flate2::mem::DecompressError

source§

impl Display for getrandom::error::Error

source§

impl Display for log::ParseLevelError

source§

impl Display for SetLoggerError

source§

impl Display for FromStrError

source§

impl Display for uuid::error::Error

source§

impl Display for Braced

source§

impl Display for Hyphenated

source§

impl Display for Simple

source§

impl Display for Urn

source§

impl Display for Uuid

source§

impl Display for rand::rngs::adapter::read::ReadError

source§

impl Display for rand_core::error::Error

source§

impl Display for Mime

§

impl Display for CompactString

§

impl Display for HeaderName

§

impl Display for Method

§

impl Display for StatusCode

Formats the status code, including the canonical reason.

§Example

assert_eq!(format!("{}", StatusCode::OK), "200 OK");
§

impl Display for Uri

source§

impl Display for AllocError

1.28.0 · source§

impl Display for LayoutError

1.36.0 · source§

impl Display for kvarn::prelude::utils::prelude::compact_str::core::array::TryFromSliceError

1.39.0 · source§

impl Display for kvarn::prelude::utils::prelude::compact_str::core::ascii::EscapeDefault

1.13.0 · source§

impl Display for BorrowError

1.13.0 · source§

impl Display for BorrowMutError

1.34.0 · source§

impl Display for CharTryFromError

1.9.0 · source§

impl Display for DecodeUtf16Error

1.20.0 · source§

impl Display for kvarn::prelude::utils::prelude::compact_str::core::char::EscapeDebug

1.16.0 · source§

impl Display for kvarn::prelude::utils::prelude::compact_str::core::char::EscapeDefault

1.16.0 · source§

impl Display for kvarn::prelude::utils::prelude::compact_str::core::char::EscapeUnicode

1.20.0 · source§

impl Display for ParseCharError

1.16.0 · source§

impl Display for ToLowercase

1.16.0 · source§

impl Display for ToUppercase

1.59.0 · source§

impl Display for TryFromCharError

1.69.0 · source§

impl Display for FromBytesUntilNulError

1.17.0 · source§

impl Display for FromBytesWithNulError

1.0.0 · source§

impl Display for ParseFloatError

1.0.0 · source§

impl Display for kvarn::prelude::utils::prelude::compact_str::core::num::ParseIntError

1.34.0 · source§

impl Display for kvarn::prelude::utils::prelude::compact_str::core::num::TryFromIntError

1.26.0 · source§

impl Display for Location<'_>

1.26.0 · source§

impl Display for PanicInfo<'_>

1.81.0 · source§

impl Display for PanicMessage<'_>

1.66.0 · source§

impl Display for TryFromFloatSecsError

§

impl Display for Drain<'_>

§

impl Display for ReserveError

§

impl Display for Utf16Error

1.0.0 · source§

impl Display for Arguments<'_>

1.0.0 · source§

impl Display for kvarn::prelude::utils::prelude::fmt::Error

§

impl Display for InvalidHeaderName

§

impl Display for InvalidHeaderValue

§

impl Display for MaxSizeReached

§

impl Display for ToStrError

1.0.0 · source§

impl Display for kvarn::prelude::utils::prelude::io::Error

1.56.0 · source§

impl Display for WriterPanicked

1.4.0 · source§

impl Display for kvarn::prelude::utils::prelude::net::AddrParseError

1.0.0 · source§

impl Display for Ipv4Addr

1.0.0 · source§

impl Display for Ipv6Addr

Writes an Ipv6Addr, conforming to the canonical style described by RFC 5952.

1.0.0 · source§

impl Display for SocketAddrV4

1.0.0 · source§

impl Display for SocketAddrV6

1.0.0 · source§

impl Display for ParseBoolError

1.0.0 · source§

impl Display for Utf8Error

§

impl Display for Authority

§

impl Display for InvalidUri

§

impl Display for InvalidUriParts

§

impl Display for PathAndQuery

§

impl Display for Scheme

§

impl Display for Aborted

§

impl Display for AcquireError

§

impl Display for AddrParseError

§

impl Display for AnyDelimiterCodecError

§

impl Display for ApplicationClose

§

impl Display for Canceled

§

impl Display for CapacityError

§

impl Display for CloseCode

§

impl Display for ClosedStream

§

impl Display for Code

§

impl Display for CollectionAllocErr

§

impl Display for ComponentRange

§

impl Display for ConfigError

§

impl Display for ConnectError

§

impl Display for ConnectionClose

§

impl Display for ConnectionError

§

impl Display for ConnectionError

§

impl Display for ConnectionId

§

impl Display for ContentSizeError

§

impl Display for Control

§

impl Display for ConversionRange

§

impl Display for Data

§

impl Display for Date

§

impl Display for DecodeError

§

impl Display for DecodeSliceError

§

impl Display for DecompressError

Available on crate feature with-alloc only.
§

impl Display for DifferentVariant

§

impl Display for Dir

§

impl Display for Duration

The format returned by this implementation is not stable and must not be relied upon.

By default this produces an exact, full-precision printout of the duration. For a concise, rounded printout instead, you can use the .N format specifier:

let duration = Duration::new(123456, 789011223);
println!("{duration:.3}");

For the purposes of this implementation, a day is exactly 24 hours and a minute is exactly 60 seconds.

§

impl Display for EarlyDataError

§

impl Display for Elapsed

§

impl Display for EncodeError

§

impl Display for EncodeSliceError

§

impl Display for EncryptError

§

impl Display for EnterError

§

impl Display for Error

§

impl Display for Error

§

impl Display for Error

§

impl Display for Error

§

impl Display for Error

§

impl Display for Error

§

impl Display for Error

§

impl Display for Error

§

impl Display for Error

§

impl Display for Error

§

impl Display for Error

§

impl Display for Error

§

impl Display for Error

§

impl Display for Error

§

impl Display for Field

§

impl Display for FieldSet

§

impl Display for FileTime

§

impl Display for FinishError

§

impl Display for Format

§

impl Display for Frame

§

impl Display for IndeterminateOffset

§

impl Display for InvalidBufferSize

§

impl Display for InvalidDnsNameError

§

impl Display for InvalidFormatDescription

§

impl Display for InvalidLength

§

impl Display for InvalidMethod

§

impl Display for InvalidOutputSize

§

impl Display for InvalidStatusCode

§

impl Display for InvalidStreamId

§

impl Display for InvalidVariant

§

impl Display for JoinError

§

impl Display for KeyRejected

§

impl Display for KeyRejected

§

impl Display for LengthDelimitedCodecError

§

impl Display for Level

§

impl Display for LevelFilter

§

impl Display for LinesCodecError

§

impl Display for Message

§

impl Display for Month

§

impl Display for NoInitialCipherSuite

§

impl Display for OpCode

§

impl Display for OtherError

§

impl Display for PacketDecodeError

§

impl Display for Parse

§

impl Display for ParseAlphabetError

§

impl Display for ParseFromDescription

§

impl Display for ParseIntError

§

impl Display for ParseLevelError

§

impl Display for ParseLevelFilterError

§

impl Display for PredicateError

§

impl Display for PrimitiveDateTime

§

impl Display for ProtocolError

§

impl Display for PushError

§

impl Display for ReadError

§

impl Display for ReadError

§

impl Display for ReadError

§

impl Display for ReadExactError

§

impl Display for ReadToEndError

§

impl Display for ReadableError

§

impl Display for Reason

§

impl Display for RecvError

§

impl Display for RecvError

§

impl Display for RecvError

§

impl Display for RecvError

§

impl Display for RecvTimeoutError

§

impl Display for ResetError

§

impl Display for RetryError

§

impl Display for RetryError

§

impl Display for ReuniteError

§

impl Display for ReuniteError

§

impl Display for SelectTimeoutError

§

impl Display for SendDatagramError

§

impl Display for SendDatagramError

§

impl Display for SendDatagramError

§

impl Display for SendError

§

impl Display for SendStreamError

§

impl Display for SetGlobalDefaultError

§

impl Display for SpawnError

§

impl Display for StoppedError

§

impl Display for StreamId

§

impl Display for StreamId

§

impl Display for SubProtocolError

§

impl Display for Time

§

impl Display for TlsError

§

impl Display for TryAcquireError

§

impl Display for TryCurrentError

§

impl Display for TryFromIntError

§

impl Display for TryFromParsed

§

impl Display for TryFromSliceError

§

impl Display for TryLockError

§

impl Display for TryRecvError

§

impl Display for TryRecvError

§

impl Display for TryRecvError

§

impl Display for TryRecvError

§

impl Display for TryRecvError

§

impl Display for TryReserveError

§

impl Display for TrySelectError

§

impl Display for Unspecified

§

impl Display for Unspecified

§

impl Display for UnsupportedOperationError

§

impl Display for UrlError

§

impl Display for UtcOffset

§

impl Display for VarInt

§

impl Display for VarIntBoundsExceeded

§

impl Display for VerifierBuilderError

§

impl Display for Weekday

§

impl Display for WriteError

§

impl Display for WriteError

§

impl Display for dyn Value

source§

impl<'a> Display for Name<'a>

source§

impl<'a> Display for Query<'a>

source§

impl<'a> Display for QueryPair<'a>

1.60.0 · source§

impl<'a> Display for EscapeAscii<'a>

1.34.0 · source§

impl<'a> Display for kvarn::prelude::utils::prelude::str::EscapeDebug<'a>

1.34.0 · source§

impl<'a> Display for kvarn::prelude::utils::prelude::str::EscapeDefault<'a>

1.34.0 · source§

impl<'a> Display for kvarn::prelude::utils::prelude::str::EscapeUnicode<'a>

§

impl<'a> Display for BufReadDecoderError<'a>

§

impl<'a> Display for DecodeError<'a>

§

impl<'a> Display for PercentEncode<'a>

§

impl<'a> Display for ValueSet<'a>

§

impl<'a, 'e, E> Display for Base64Display<'a, 'e, E>
where E: Engine,

source§

impl<'a, G> Display for Dot<'a, G>

source§

impl<'a, K, V> Display for std::collections::hash::map::OccupiedError<'a, K, V>
where K: Debug, V: Debug,

source§

impl<'a, K, V, A> Display for alloc::collections::btree::map::entry::OccupiedError<'a, K, V, A>
where K: Debug + Ord, V: Debug, A: Allocator + Clone,

§

impl<'a, K, V, S, A> Display for OccupiedError<'a, K, V, S, A>
where K: Debug, V: Debug, A: Allocator,

§

impl<'a, K, V, S, A> Display for OccupiedError<'a, K, V, S, A>
where K: Debug, V: Debug, A: Allocator,

§

impl<'a, K, V, T> Display for MappedRef<'a, K, V, T>
where K: Eq + Hash, T: Display,

§

impl<'a, R, G, T> Display for MappedReentrantMutexGuard<'a, R, G, T>
where R: RawMutex + 'a, G: GetThreadId + 'a, T: Display + 'a + ?Sized,

§

impl<'a, R, G, T> Display for ReentrantMutexGuard<'a, R, G, T>
where R: RawMutex + 'a, G: GetThreadId + 'a, T: Display + 'a + ?Sized,

§

impl<'a, R, T> Display for MappedMutexGuard<'a, R, T>
where R: RawMutex + 'a, T: Display + 'a + ?Sized,

§

impl<'a, R, T> Display for MappedRwLockReadGuard<'a, R, T>
where R: RawRwLock + 'a, T: Display + 'a + ?Sized,

§

impl<'a, R, T> Display for MappedRwLockWriteGuard<'a, R, T>
where R: RawRwLock + 'a, T: Display + 'a + ?Sized,

§

impl<'a, R, T> Display for MutexGuard<'a, R, T>
where R: RawMutex + 'a, T: Display + 'a + ?Sized,

§

impl<'a, R, T> Display for RwLockReadGuard<'a, R, T>
where R: RawRwLock + 'a, T: Display + 'a + ?Sized,

§

impl<'a, R, T> Display for RwLockUpgradableReadGuard<'a, R, T>
where R: RawRwLockUpgrade + 'a, T: Display + 'a + ?Sized,

§

impl<'a, R, T> Display for RwLockWriteGuard<'a, R, T>
where R: RawRwLock + 'a, T: Display + 'a + ?Sized,

source§

impl<'a, T> Display for CleanDebug<'a, T>
where T: Display + ?Sized,

§

impl<'a, T> Display for MappedMutexGuard<'a, T>
where T: Display + ?Sized,

§

im