Trait display_tree::StyleBuilder
source · pub trait StyleBuilder: Sized {
Show 13 methods
fn char_set(self, char_set: CharSet) -> Self { ... }
fn indentation(self, indentation: u32) -> Self { ... }
fn leaf_color(self, color: Color) -> Self { ... }
fn leaf_background_color(self, color: Color) -> Self { ... }
fn bold_leaves(self) -> Self { ... }
fn faint_leaves(self) -> Self { ... }
fn italic_leaves(self) -> Self { ... }
fn underlined_leaves(self) -> Self { ... }
fn strikethrough_leaves(self) -> Self { ... }
fn branch_color(self, color: Color) -> Self { ... }
fn branch_background_color(self, color: Color) -> Self { ... }
fn bold_branches(self) -> Self { ... }
fn faint_branches(self) -> Self { ... }
}
Expand description
A trait that provides builder methods for constructing an instance of
Style
.
StyleBuilder
is implemented for Style
and AsTree
, so you can use
those types to construct an instance of Style
.
Do not implement StyleBuilder
for any new types.
Provided Methods§
sourcefn char_set(self, char_set: CharSet) -> Self
fn char_set(self, char_set: CharSet) -> Self
Sets the CharSet
making up the branches of the tree.
See CharSet
for more information.
Examples
use display_tree::{AsTree, CharSet, DisplayTree, StyleBuilder};
#[derive(DisplayTree)]
struct Tree {
a: i32,
b: i32,
}
let tree = Tree { a: 1, b: 2 };
assert_eq!(
format!(
"{}",
// Use ASCII characters instead of the default Unicode ones.
AsTree::new(&tree).char_set(CharSet::ASCII),
),
"Tree\n\
|-- 1\n\
`-- 2",
);
sourcefn indentation(self, indentation: u32) -> Self
fn indentation(self, indentation: u32) -> Self
Sets the indentation of each node.
More specifically, indentation()
sets the
number of horizontal characters to use for each branch of the tree.
Examples
use display_tree::{AsTree, DisplayTree, StyleBuilder};
#[derive(DisplayTree)]
struct Tree {
a: i32,
b: i32,
}
let tree = Tree { a: 1, b: 2 };
assert_eq!(
format!("{}", AsTree::new(&tree).indentation(4),),
"Tree\n\
├──── 1\n\
└──── 2"
);
sourcefn leaf_color(self, color: Color) -> Self
fn leaf_color(self, color: Color) -> Self
Sets the color of the leaves of the tree. See Color
for more
information.
sourcefn leaf_background_color(self, color: Color) -> Self
fn leaf_background_color(self, color: Color) -> Self
Sets the background color of the leaves of the tree. See Color
for
more information.
sourcefn bold_leaves(self) -> Self
fn bold_leaves(self) -> Self
Renders the leaves as bold.
sourcefn faint_leaves(self) -> Self
fn faint_leaves(self) -> Self
Decreases the intensity of the leaves.
sourcefn italic_leaves(self) -> Self
fn italic_leaves(self) -> Self
Italicises the leaves.
sourcefn underlined_leaves(self) -> Self
fn underlined_leaves(self) -> Self
Underlines the leaves.
sourcefn strikethrough_leaves(self) -> Self
fn strikethrough_leaves(self) -> Self
Causes the leaves to be crossed-out.
sourcefn branch_color(self, color: Color) -> Self
fn branch_color(self, color: Color) -> Self
Sets the color of the branches of the tree. See Color
for more
information.
sourcefn branch_background_color(self, color: Color) -> Self
fn branch_background_color(self, color: Color) -> Self
Sets the background color of the branches of the tree. See Color
for
more information.
sourcefn bold_branches(self) -> Self
fn bold_branches(self) -> Self
Renders the branches as bold.
sourcefn faint_branches(self) -> Self
fn faint_branches(self) -> Self
Decreases the intensity of the branches.