-
-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathvisualizer.rs
More file actions
66 lines (62 loc) · 2.2 KB
/
visualizer.rs
File metadata and controls
66 lines (62 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
pub mod bar_alignment;
pub mod child_position;
pub mod column_width_distribution;
pub mod direction;
pub mod parenthood;
pub mod proportion_bar;
pub mod tree;
pub use bar_alignment::BarAlignment;
pub use child_position::ChildPosition;
pub use column_width_distribution::ColumnWidthDistribution;
pub use direction::Direction;
pub use parenthood::Parenthood;
pub use proportion_bar::{ProportionBar, ProportionBarBlock};
pub use tree::{TreeHorizontalSlice, TreeSkeletalComponent};
use super::{data_tree::DataTree, size};
use bon::Builder;
use std::fmt::Display;
/// Visualize a [`DataTree`].
///
/// The fields of the struct are the construction parameters of the ASCII chart.
/// The [`Display`] trait can be used to create the ASCII chart.
///
/// **Example:**
///
/// ```no_run
/// # use parallel_disk_usage::data_tree::DataTree;
/// # use parallel_disk_usage::os_string_display::OsStringDisplay;
/// # use parallel_disk_usage::size::Bytes;
/// # use parallel_disk_usage::bytes_format::BytesFormat;
/// # use parallel_disk_usage::visualizer::{Visualizer, Direction, BarAlignment, ColumnWidthDistribution};
/// # fn _wrapper(create_data_tree: fn() -> DataTree<OsStringDisplay, Bytes>) {
/// let data_tree: DataTree<OsStringDisplay, Bytes> = create_data_tree();
/// let visualizer = Visualizer::builder()
/// .data_tree(&data_tree)
/// .bytes_format(BytesFormat::MetricUnits)
/// .direction(Direction::BottomUp)
/// .bar_alignment(BarAlignment::Right)
/// .column_width_distribution(ColumnWidthDistribution::total(100))
/// .build();
/// println!("{visualizer}");
/// # }
/// ```
#[derive(Debug, Builder)]
pub struct Visualizer<'a, Name, Size>
where
Name: Display,
Size: size::Size,
{
/// The tree to visualize.
pub data_tree: &'a DataTree<Name, Size>,
/// Format to be used to [`display`](size::Size::display) the sizes.
pub bytes_format: Size::DisplayFormat,
/// The direction of the visualization of the tree.
pub direction: Direction,
/// The alignment of the bars.
pub bar_alignment: BarAlignment,
/// Distribution and total number of characters/blocks can be placed in a line.
pub column_width_distribution: ColumnWidthDistribution,
}
mod copy;
mod display;
mod methods;