TreeItem

Trait TreeItem 

Source
pub trait TreeItem: Clone {
    type Child: TreeItem;

    // Required methods
    fn write_self<W: Write>(&self, f: &mut W, style: &Style) -> Result<()>;
    fn children(&self) -> Cow<'_, [Self::Child]>;
}
Expand description

Main trait for exposing a tree structure to ptree

Required Associated Types§

Source

type Child: TreeItem

The type of this item’s child items

This is usually Self, but may be any type that itself implements TreeItem.

Required Methods§

Source

fn write_self<W: Write>(&self, f: &mut W, style: &Style) -> Result<()>

Write the item’s own contents (without children) to f

The function returns an io::Result<()>, so calls to f.write and write! can be chained with ?.

The provided style may be used for formatting hints. Usually, everything printed should be run through style.paint. However, this is not enforced, and custom implementations may choose to format only parts of the output, apply its own formatting in combination with the provided config, or ignore formatting altogether.

Source

fn children(&self) -> Cow<'_, [Self::Child]>

Retrieve a list of this item’s children

If the items contains no children (it is a leaf item), this method returns an empty list.

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.

Implementations on Foreign Types§

Source§

impl TreeItem for (String, Value)

Source§

type Child = (String, Value)

Source§

fn write_self<W: Write>(&self, f: &mut W, style: &Style) -> Result<()>

Source§

fn children(&self) -> Cow<'_, [Self::Child]>

Source§

impl TreeItem for Value

Source§

type Child = (String, Value)

Source§

fn write_self<W: Write>(&self, f: &mut W, style: &Style) -> Result<()>

Source§

fn children(&self) -> Cow<'_, [Self::Child]>

Source§

impl<'a, N, E, Ty, Ix> TreeItem for (&'a Graph<N, E, Ty, Ix>, NodeIndex<Ix>)
where Ty: EdgeType, Ix: IndexType, N: Clone + Display, E: Clone,

Source§

type Child = (&'a Graph<N, E, Ty, Ix>, NodeIndex<Ix>)

Source§

fn write_self<W: Write>(&self, f: &mut W, style: &Style) -> Result<()>

Source§

fn children(&self) -> Cow<'_, [Self::Child]>

Implementors§