Skip to main content

Display

Trait Display 

Source
pub trait Display {
    // Required method
    fn print_content(&self, out: &mut Output<'_>) -> Result;

    // Provided methods
    fn print(&self, out: &mut Output<'_>) -> Result { ... }
    fn header_footer(&self) -> Option<(String, String)> { ... }
    fn start_same_line(&self) -> bool { ... }
}
Expand description

Display the value to the user.

This trait is kind of similar to std::fmt::Display, although far more simple. This is a different trait than std::fmt::Display as graph exploring display may be different than “classical” display.

Required Methods§

Source

fn print_content(&self, out: &mut Output<'_>) -> Result

Print the content of the value.

If value is kind of a struct, header_footer should be implemented and print_content should print only the fields of the value. Else, print_content should simply print the value.

Provided Methods§

Source

fn print(&self, out: &mut Output<'_>) -> Result

Print the value to out.

Default implementation reuse header_footer and print_content to display the value, using a format like:

header
   content
footer

or simply (if not header/footer):

content

User should probably not reimplement print.

Return the header and footer of the value.

Default implementation returns None. One may want to implement it as:

  • Some((String::from("Foo:"), String::new()))
  • Some((String::from("Foo("), String::from(")")))
Source

fn start_same_line(&self) -> bool

Tell if value display can start on same line than prefix.

When the value render on several line and displayed as field value of parent structure, if strat_same_line() is true, the first line will be display on the same line of the field prefix:

foo: <first line>
  <other lines>
  ...

When start_same_line() is false:

foo:
   <first line>
   <other lines>
   ...

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Display for &str

Source§

fn print_content(&self, out: &mut Output<'_>) -> Result

Source§

impl Display for String

Source§

fn print_content(&self, out: &mut Output<'_>) -> Result

Source§

impl Display for bool

Source§

fn print_content(&self, out: &mut Output<'_>) -> Result

Source§

impl Display for f32

Source§

fn print_content(&self, out: &mut Output<'_>) -> Result

Source§

impl Display for f64

Source§

fn print_content(&self, out: &mut Output<'_>) -> Result

Source§

impl Display for i8

Source§

fn print_content(&self, out: &mut Output<'_>) -> Result

Source§

impl Display for i16

Source§

fn print_content(&self, out: &mut Output<'_>) -> Result

Source§

impl Display for i32

Source§

fn print_content(&self, out: &mut Output<'_>) -> Result

Source§

impl Display for i64

Source§

fn print_content(&self, out: &mut Output<'_>) -> Result

Source§

impl Display for i128

Source§

fn print_content(&self, out: &mut Output<'_>) -> Result

Source§

impl Display for isize

Source§

fn print_content(&self, out: &mut Output<'_>) -> Result

Source§

impl Display for u8

Source§

fn print_content(&self, out: &mut Output<'_>) -> Result

Source§

impl Display for u16

Source§

fn print_content(&self, out: &mut Output<'_>) -> Result

Source§

impl Display for u32

Source§

fn print_content(&self, out: &mut Output<'_>) -> Result

Source§

impl Display for u64

Source§

fn print_content(&self, out: &mut Output<'_>) -> Result

Source§

impl Display for u128

Source§

fn print_content(&self, out: &mut Output<'_>) -> Result

Source§

impl Display for usize

Source§

fn print_content(&self, out: &mut Output<'_>) -> Result

Source§

impl<K, T> Display for HashMap<K, T>
where T: Display, K: AsRef<str>,

Source§

fn print_content(&self, out: &mut Output<'_>) -> Result

Source§

impl<T, U> Display for (T, U)
where T: Display, U: Display,

Source§

fn print_content(&self, out: &mut Output<'_>) -> Result

Source§

impl<T> Display for Arc<T>
where T: Display,

Source§

fn print_content(&self, out: &mut Output<'_>) -> Result

Source§

impl<T> Display for Option<T>
where T: Display,

Source§

fn print_content(&self, out: &mut Output<'_>) -> Result

Source§

impl<T> Display for Rc<T>
where T: Display,

Source§

fn print_content(&self, out: &mut Output<'_>) -> Result

Source§

impl<T> Display for Vec<T>
where T: Display,

Source§

fn print_content(&self, out: &mut Output<'_>) -> Result

Implementors§