Trait DisplayConfig

Source
pub trait DisplayConfig: Sized {
    // Required method
    fn context_mut(&mut self) -> &mut Context;

    // Provided methods
    fn verbose(self) -> Self { ... }
    fn limit_items(self, max_items: usize) -> Self { ... }
    fn use_local_time(self) -> Self { ... }
    fn use_utc_time(self) -> Self { ... }
    fn use_short_time(self) -> Self { ... }
    fn use_full_time(self) -> Self { ... }
    fn with_time_format(self, time_format: &'static str) -> Self { ... }
}
Expand description

A customizable display wrapper.

Provides a builder-style interface to control how values are formatted when displayed. Supports configuration of:

  • Verbosity level (e.g., Some(1) vs 1)
  • Collection size limits
  • Time formatting options (timezone and format patterns)

§Example:

use to_display::DisplayConfig;
use to_display::ToDisplay;

assert_eq!(Some(1u32).display().to_string(), "1");
assert_eq!(Some(1u32).display().verbose().to_string(), "Some(1)");

Required Methods§

Source

fn context_mut(&mut self) -> &mut Context

Return a mutable reference to the context to let the caller modify it.

Provided Methods§

Source

fn verbose(self) -> Self

Enable verbose mode: Display Option with Some(v)/None or v/-

Source

fn limit_items(self, max_items: usize) -> Self

Set the maximum number of items to display for collections.

Applies to slices, vectors, maps, and other collection types. Elements beyond this limit will be indicated with an ellipsis.

Source

fn use_local_time(self) -> Self

Configures timestamps to display in local time.

Source

fn use_utc_time(self) -> Self

Configures timestamps to display in UTC.

Source

fn use_short_time(self) -> Self

Sets a concise time format (%H:%M:%S%.6f).

Source

fn use_full_time(self) -> Self

Sets a detailed time format (%Y-%m-%dT%H:%M:%S%.6fZ%z).

Source

fn with_time_format(self, time_format: &'static str) -> Self

Sets a custom time format string.

Uses the format syntax from the chrono crate. See chrono::format::strftime for the full specification.

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.

Implementors§

Source§

impl<K, V> DisplayConfig for DisplayBTreeMap<'_, K, V>

Source§

impl<T> DisplayConfig for DisplayOption<'_, T>

Source§

impl<T> DisplayConfig for DisplaySlice<'_, T>

Source§

impl<T, E> DisplayConfig for DisplayResult<'_, T, E>