pub struct NodeLineBuilder { /* private fields */ }Expand description
Builder for TreeNode::Node’s text line.
Implementations§
Source§impl NodeLineBuilder
impl NodeLineBuilder
Sourcepub fn end(self) -> NodeBuilder
pub fn end(self) -> NodeBuilder
Examples found in repository?
examples/tree.rs (line 20)
3fn main() {
4 // Collect the command-line arguments.
5 let args = std::env::args().collect::<Vec<String>>();
6
7 // The first argument may be the color mode, like: auto, never, always
8 let color_mode = if args.len() > 1 { ColorMode::new(&args[1]) } else { ColorMode::default() };
9
10 // The second argument should be the indentation, the tree will be shifted to the right.
11 let indent = if args.len() > 2 { args[2].parse::<usize>().unwrap_or_default() } else { 0 };
12
13 // Build the tree.
14 let root = node(Color::Rgb((80, 12, 140)), color_mode)
15 .line()
16 .bold()
17 .underline()
18 .blue()
19 .s("Quantum AI Core")
20 .end()
21 .child(
22 node(Color::Yellow, color_mode)
23 .line()
24 .yellow()
25 .s("Neural Processing Unit Alpha")
26 .end()
27 .child(
28 leaf(color_mode)
29 .line()
30 .s("Synapse Array Load: 98%")
31 .end()
32 .line()
33 .s("Memory Cache Temp: -12°C")
34 .end()
35 .line()
36 .magenta()
37 .s("Quantum Bit Flux: 0.0012")
38 .end()
39 .line()
40 .bg_yellow()
41 .color(Color::Rgb((10, 10, 10)))
42 .s(" Neural Spike Rate: 14,000 Hz ")
43 .end()
44 .end(),
45 )
46 .child(leaf(color_mode).line().s("Optimization Status: ").green().bold().s("Perfect").end().end())
47 .end(),
48 )
49 .child(
50 node(Color::None, color_mode)
51 .line()
52 .bold()
53 .blue()
54 .s("Dark Matter Storage Array")
55 .end()
56 .child(leaf(color_mode).line().s("Energy Stabilizer: Online").end().end())
57 .child(
58 leaf(color_mode)
59 .line()
60 .s("Matter Density: 9.8×10^-27 kg/m³")
61 .end()
62 .line()
63 .s("Containment Field: 99.99%")
64 .end()
65 .line()
66 .bold()
67 .red()
68 .s("Particle Flux: 1.2×10^6 s^-1")
69 .end()
70 .line()
71 .s("Storage Efficiency: 87%")
72 .end()
73 .end(),
74 )
75 .child(leaf(color_mode).line().s("Backup Node: ").green().bold().underline().s("Ready").end().end())
76 .end(),
77 )
78 .child(
79 node(Color::None, color_mode)
80 .line()
81 .bold()
82 .blue()
83 .s("Interstellar Communication Hub")
84 .end()
85 .child(
86 node(Color::Yellow, color_mode)
87 .line()
88 .yellow()
89 .s("Subspace Transmitter Delta")
90 .end()
91 .child(
92 leaf(color_mode)
93 .line()
94 .s("Signal Strength: 999.9 TW")
95 .end()
96 .line()
97 .cyan()
98 .s("Latency: 0.00042 s")
99 .end()
100 .line()
101 .s("Encryption Protocol: Quantum-256")
102 .end()
103 .line()
104 .s("Active Channels: 42")
105 .end()
106 .end(),
107 )
108 .child(leaf(color_mode).line().s("Maintenance Mode: ").italic().bg_magenta().s("Idle").end().end())
109 .end(),
110 )
111 .child(
112 leaf(color_mode)
113 .line()
114 .cyan()
115 .s("Cosmic Bandwidth Allocation: 12.7 PB/s")
116 .end()
117 .line()
118 .s("Error Correction Status: Optimal")
119 .end()
120 .line()
121 .s("Packet Loss: 0.0001%")
122 .end()
123 .line()
124 .s("Routing Algorithm: Self-Adaptive AI")
125 .end()
126 .end(),
127 )
128 .child(leaf(color_mode).line().s("Hub Status: ").green().italic().bold().s("Fully Operational").end().end())
129 .end(),
130 )
131 .end();
132
133 // Print the tree with indentation.
134 print!("{:1$}", root, indent);
135}Trait Implementations§
Source§impl Clone for NodeLineBuilder
impl Clone for NodeLineBuilder
Source§fn clone(&self) -> NodeLineBuilder
fn clone(&self) -> NodeLineBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for NodeLineBuilder
impl Debug for NodeLineBuilder
Source§impl StyledText for NodeLineBuilder
impl StyledText for NodeLineBuilder
Source§fn plural<T: Display>(self, s: T, n: usize) -> Self
fn plural<T: Display>(self, s: T, n: usize) -> Self
Adds
s suffix to the content when the number is not 1.Source§fn align_left<T: Display>(self, s: T, width: usize) -> Self
fn align_left<T: Display>(self, s: T, width: usize) -> Self
Adds the content aligned left with specified width.
Source§fn align_right<T: Display>(self, s: T, width: usize) -> Self
fn align_right<T: Display>(self, s: T, width: usize) -> Self
Adds the content aligned right with specified width.
Source§fn align_center<T: Display>(self, s: T, width: usize) -> Self
fn align_center<T: Display>(self, s: T, width: usize) -> Self
Adds the content centered with specified width.
Source§fn pad<T: Display>(self, ch: char, padding: usize, s: T) -> Self
fn pad<T: Display>(self, ch: char, padding: usize, s: T) -> Self
Pads the content with specified character.
Source§fn pad_left<T: Display>(self, ch: char, s: T, width: usize) -> Self
fn pad_left<T: Display>(self, ch: char, s: T, width: usize) -> Self
Pads the content aligned the left with specified width.
Source§fn pad_right<T: Display>(self, ch: char, s: T, width: usize) -> Self
fn pad_right<T: Display>(self, ch: char, s: T, width: usize) -> Self
Pads the content aligned right with specified width.
Source§fn pad_center<T: Display>(self, ch: char, s: T, width: usize) -> Self
fn pad_center<T: Display>(self, ch: char, s: T, width: usize) -> Self
Pads the content centered with specified width.
Source§fn choose<T: Display>(
self,
condition: bool,
when_true: T,
when_false: T,
) -> Self
fn choose<T: Display>( self, condition: bool, when_true: T, when_false: T, ) -> Self
Adds new content based on the condition.
Source§fn bright_black(self) -> Self
fn bright_black(self) -> Self
Sets the foreground color to bright black.
Source§fn bright_red(self) -> Self
fn bright_red(self) -> Self
Sets the foreground color to bright red.
Source§fn bright_green(self) -> Self
fn bright_green(self) -> Self
Sets the foreground color to bright green.
Source§fn bright_yellow(self) -> Self
fn bright_yellow(self) -> Self
Sets the foreground color to bright yellow.
Source§fn bright_blue(self) -> Self
fn bright_blue(self) -> Self
Sets the foreground color to bright blue.
Source§fn bright_magenta(self) -> Self
fn bright_magenta(self) -> Self
Sets the foreground color to bright magenta.
Source§fn bright_cyan(self) -> Self
fn bright_cyan(self) -> Self
Sets the foreground color to bright cyan.
Source§fn bright_white(self) -> Self
fn bright_white(self) -> Self
Sets the foreground color to bright white.
Source§fn bg_bright_black(self) -> Self
fn bg_bright_black(self) -> Self
Sets the background color to bright black.
Source§fn bg_bright_red(self) -> Self
fn bg_bright_red(self) -> Self
Sets the background color to bright red.
Source§fn bg_bright_green(self) -> Self
fn bg_bright_green(self) -> Self
Sets the background color to bright green.
Source§fn bg_bright_yellow(self) -> Self
fn bg_bright_yellow(self) -> Self
Sets the background color to bright yellow.
Source§fn bg_bright_blue(self) -> Self
fn bg_bright_blue(self) -> Self
Sets the background color to bright blue.
Source§fn bg_magenta(self) -> Self
fn bg_magenta(self) -> Self
Sets the background color to magenta.
Source§fn bg_bright_magenta(self) -> Self
fn bg_bright_magenta(self) -> Self
Sets the background color to bright magenta.
Source§fn bg_bright_cyan(self) -> Self
fn bg_bright_cyan(self) -> Self
Sets the background color to bright cyan.
Source§fn bg_bright_white(self) -> Self
fn bg_bright_white(self) -> Self
Sets the background color to bright white.
Source§fn bright_color(self, c: Color) -> Self
fn bright_color(self, c: Color) -> Self
Sets the bright color by color enumeration.
Source§fn bg_bright_color(self, c: Color) -> Self
fn bg_bright_color(self, c: Color) -> Self
Sets the background bright color by color enumeration.
Source§fn bright_color_8(self, c: u8) -> Self
fn bright_color_8(self, c: u8) -> Self
Sets the bright color by color index.
Source§fn bg_color_8(self, c: u8) -> Self
fn bg_color_8(self, c: u8) -> Self
Sets the background color by color index.
Source§fn bg_bright_color_8(self, c: u8) -> Self
fn bg_bright_color_8(self, c: u8) -> Self
Sets the background bright color by color index.
fn color_256(self, c: u8) -> Self
fn bg_color_256(self, c: u8) -> Self
fn color_rgb(self, c: RgbColor) -> Self
fn bg_color_rgb(self, c: RgbColor) -> Self
Auto Trait Implementations§
impl Freeze for NodeLineBuilder
impl RefUnwindSafe for NodeLineBuilder
impl Send for NodeLineBuilder
impl Sync for NodeLineBuilder
impl Unpin for NodeLineBuilder
impl UnsafeUnpin for NodeLineBuilder
impl UnwindSafe for NodeLineBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more