pub trait Displayable {
// Required method
fn oneline_display(&self) -> String;
// Provided methods
fn print_full(&self, epoch_info: &EpochInfo) { ... }
fn short_display(&self, _epoch_info: &EpochInfo) -> String { ... }
}Expand description
A trait for types that can be displayed in a command-line tool.
Implementors should provide three levels of representation:
- Full - a detailed view suitable for a long-running command.
- Short - a concise, user-friendly view that fits on a single line.
- Oneline - a compact, machine-friendly string that can be embedded
inside a
Vec<T>representation.
§Vec<T> support
The trait is implemented generically for Vec<T> as long as T: Displayable.
This allows you to call full_display, short_display or oneline_display
directly on a vector of displayable items.
Required Methods§
Sourcefn oneline_display(&self) -> String
fn oneline_display(&self) -> String
Return a one-liner string, suitable for embedding in a collection
representation (e.g. a Vec<T>). Implementations should avoid
new-lines to keep the output usable in a single line context.
Provided Methods§
Sourcefn print_full(&self, epoch_info: &EpochInfo)
fn print_full(&self, epoch_info: &EpochInfo)
Return a fully-described string representation.
Sourcefn short_display(&self, _epoch_info: &EpochInfo) -> String
fn short_display(&self, _epoch_info: &EpochInfo) -> String
Return a short, user-friendly string. Resolves Ids
Implementations on Foreign Types§
Source§impl<T: Displayable> Displayable for Vec<T>
Implement Displayable for vectors of displayable items.
impl<T: Displayable> Displayable for Vec<T>
Implement Displayable for vectors of displayable items.
The implementation simply delegates to the underlying T::oneline_display
method and joins the results with a comma. It works for any T that
already implements Displayable. This is a blanket implementation,
so you do not need to write a manual impl for each concrete type