tree_view

Crates.iotree_view
lib.rstree_view
version0.1.2
created_at2025-10-20 12:56:23.990323+00
updated_at2025-10-21 15:46:58.306442+00
descriptionA library to give out a view of a tree structure. Tree structures need to implement the trait TreeView.
homepagehttps://github.com/the-forklift/tree_view
repositoryhttps://github.com/the-forklift/tree_view
max_upload_size
id1891877
size25,411
Tim Gravert (functional-tim)

documentation

README

tree_view

Crates.io License dependency status


What this is

A library which easily formats tree structures into a view. This can be the output of an cli or part of a view in a tui.

Tree structures just need to implement the trait TreeView.

The trait TreeView has only one implementation of the function fn to_node(&self) -> Node.

An example implementation for the struct TestMap:

#derive[Eq, Ord, PartialEq, PartialOrd]
pub struct TestMap {
    pub key: String,
    pub value: Vec<TestMap>,
}

impl ToTreeView for TestMap {
    fn to_node(&self) -> Node {
        node: self.key.clone(),
        children: self.value.iter().map(|v| v.to_node()).collect(),
    }
}

Output of a TestMap:

Root
├── Leaf1
├── Node1
│   ├── Leaf2
│   └── Node2
│       ├── Leaf3
│       └── Leaf4
├── Node3
│   └── Leaf5
└── Node4
    └── Leaf6

How to install

Using cargo

You need to install cargo on your system through your package manager or any other means.

Then you simply install it through cargo.

$ > cargo install tree_view

Using source

You need to install cargo on your system through your package manager or any other means.

The you download the repository through git or manual.

After unpacking or downloading from git you have to switch into the folder of tree_view.

Then run cargo install --path ..

$ > cd tree_view
$ > cargo install --path .

License

tree_view is dual licensed under MIT License and Apache 2 License

Commit count: 0

cargo fmt