pub trait StyleBuilder: Sized {
Show 15 methods
// Provided methods
fn char_set(self, char_set: CharSet) -> Self { ... }
fn indentation(self, indentation: u32) -> Self { ... }
fn leaf_style(self, style: TextStyle) -> Self { ... }
fn branch_style(self, style: TextStyle) -> 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_style(self, style: TextStyle) -> Self
fn leaf_style(self, style: TextStyle) -> Self
Sets the style of the leaves of the tree. See TextStyle for more
information.
Sourcefn branch_style(self, style: TextStyle) -> Self
fn branch_style(self, style: TextStyle) -> Self
Sets the style of the branches of the tre. See TextStyle for more
information.
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.
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.