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)
vs1
) - 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§
Sourcefn context_mut(&mut self) -> &mut Context
fn context_mut(&mut self) -> &mut Context
Return a mutable reference to the context to let the caller modify it.
Provided Methods§
Sourcefn limit_items(self, max_items: usize) -> Self
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.
Sourcefn use_local_time(self) -> Self
fn use_local_time(self) -> Self
Configures timestamps to display in local time.
Sourcefn use_utc_time(self) -> Self
fn use_utc_time(self) -> Self
Configures timestamps to display in UTC.
Sourcefn use_short_time(self) -> Self
fn use_short_time(self) -> Self
Sets a concise time format (%H:%M:%S%.6f
).
Sourcefn use_full_time(self) -> Self
fn use_full_time(self) -> Self
Sets a detailed time format (%Y-%m-%dT%H:%M:%S%.6fZ%z
).
Sourcefn with_time_format(self, time_format: &'static str) -> Self
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.