pub struct NodeList<BackendT, ContextT, ErrorT, IdT, DataT>(pub Vec<Node<BackendT, ContextT, ErrorT, IdT, DataT>>);Expand description
Tree node list.
Tuple Fields§
§0: Vec<Node<BackendT, ContextT, ErrorT, IdT, DataT>>Implementations§
Source§impl<BackendT, ContextT, ErrorT, IdT, DataT> NodeList<BackendT, ContextT, ErrorT, IdT, DataT>
impl<BackendT, ContextT, ErrorT, IdT, DataT> NodeList<BackendT, ContextT, ErrorT, IdT, DataT>
Sourcepub fn iter(
&self,
only_expanded: bool,
) -> NodeIterator<'_, BackendT, ContextT, ErrorT, IdT, DataT> ⓘ
pub fn iter( &self, only_expanded: bool, ) -> NodeIterator<'_, BackendT, ContextT, ErrorT, IdT, DataT> ⓘ
Iterate nodes in visual order from top to bottom.
When only_expanded is true will skip the children of collapsed branches.
Sourcepub fn at_path(
&self,
path: NodePath,
) -> Option<&Node<BackendT, ContextT, ErrorT, IdT, DataT>>where
BackendT: TreeBackend<ContextT, ErrorT, IdT, DataT>,
pub fn at_path(
&self,
path: NodePath,
) -> Option<&Node<BackendT, ContextT, ErrorT, IdT, DataT>>where
BackendT: TreeBackend<ContextT, ErrorT, IdT, DataT>,
Get node at path.
Sourcepub fn at_path_mut(
&mut self,
path: NodePath,
) -> Option<&mut Node<BackendT, ContextT, ErrorT, IdT, DataT>>where
BackendT: TreeBackend<ContextT, ErrorT, IdT, DataT>,
pub fn at_path_mut(
&mut self,
path: NodePath,
) -> Option<&mut Node<BackendT, ContextT, ErrorT, IdT, DataT>>where
BackendT: TreeBackend<ContextT, ErrorT, IdT, DataT>,
Get node at path.
Sourcepub fn fill_path(
&self,
path: &mut NodePath,
node: &Node<BackendT, ContextT, ErrorT, IdT, DataT>,
) -> boolwhere
BackendT: TreeBackend<ContextT, ErrorT, IdT, DataT>,
pub fn fill_path(
&self,
path: &mut NodePath,
node: &Node<BackendT, ContextT, ErrorT, IdT, DataT>,
) -> boolwhere
BackendT: TreeBackend<ContextT, ErrorT, IdT, DataT>,
Fill path to node.
Returns true if found.
Sourcepub fn add(
&mut self,
depth: usize,
kind: NodeKind,
id: IdT,
representation: Representation,
)where
BackendT: TreeBackend<ContextT, ErrorT, IdT, DataT>,
pub fn add(
&mut self,
depth: usize,
kind: NodeKind,
id: IdT,
representation: Representation,
)where
BackendT: TreeBackend<ContextT, ErrorT, IdT, DataT>,
Add a node.
Examples found in repository?
examples/file_browser.rs (line 124)
102fn node_list(
103 depth: usize,
104 directory: &PathBuf,
105) -> Result<NodeList<FileBackend, Arc<PathBuf>, io::Error, PathBuf, Metadata>, io::Error> {
106 let mut list = NodeList::default();
107
108 for entry in read_dir(directory)? {
109 let entry = entry?;
110
111 let kind = if entry.file_type()?.is_dir() { NodeKind::Branch } else { NodeKind::Leaf };
112
113 let file_name = entry.file_name();
114 let file_name = file_name.to_string_lossy();
115
116 // We'll use different styles for leaves and branches
117 let mut representation = Representation::default();
118 if kind.is_branch() {
119 representation.append_styled(file_name, Style::title_primary());
120 } else {
121 representation.append_styled(file_name, Style::title_secondary());
122 }
123
124 list.add(depth, kind, entry.path(), representation);
125 }
126
127 Ok(list)
128}Sourcepub fn insert(
&mut self,
index: usize,
depth: usize,
kind: NodeKind,
id: IdT,
representation: Representation,
)where
BackendT: TreeBackend<ContextT, ErrorT, IdT, DataT>,
pub fn insert(
&mut self,
index: usize,
depth: usize,
kind: NodeKind,
id: IdT,
representation: Representation,
)where
BackendT: TreeBackend<ContextT, ErrorT, IdT, DataT>,
Insert a node.
Trait Implementations§
Source§impl<BackendT, ContextT, ErrorT, IdT, DataT> Default for NodeList<BackendT, ContextT, ErrorT, IdT, DataT>
impl<BackendT, ContextT, ErrorT, IdT, DataT> Default for NodeList<BackendT, ContextT, ErrorT, IdT, DataT>
Source§impl<BackendT, ContextT, ErrorT, IdT, DataT> From<Vec<Node<BackendT, ContextT, ErrorT, IdT, DataT>>> for NodeList<BackendT, ContextT, ErrorT, IdT, DataT>
impl<BackendT, ContextT, ErrorT, IdT, DataT> From<Vec<Node<BackendT, ContextT, ErrorT, IdT, DataT>>> for NodeList<BackendT, ContextT, ErrorT, IdT, DataT>
Source§impl<BackendT, ContextT, ErrorT, IdT, DataT> FromIterator<Node<BackendT, ContextT, ErrorT, IdT, DataT>> for NodeList<BackendT, ContextT, ErrorT, IdT, DataT>
impl<BackendT, ContextT, ErrorT, IdT, DataT> FromIterator<Node<BackendT, ContextT, ErrorT, IdT, DataT>> for NodeList<BackendT, ContextT, ErrorT, IdT, DataT>
Source§impl<'this, BackendT, ContextT, ErrorT, IdT, DataT> IntoIterator for &'this NodeList<BackendT, ContextT, ErrorT, IdT, DataT>
impl<'this, BackendT, ContextT, ErrorT, IdT, DataT> IntoIterator for &'this NodeList<BackendT, ContextT, ErrorT, IdT, DataT>
Source§impl<'this, BackendT, ContextT, ErrorT, IdT, DataT> IntoIterator for &'this mut NodeList<BackendT, ContextT, ErrorT, IdT, DataT>
impl<'this, BackendT, ContextT, ErrorT, IdT, DataT> IntoIterator for &'this mut NodeList<BackendT, ContextT, ErrorT, IdT, DataT>
Auto Trait Implementations§
impl<BackendT, ContextT, ErrorT, IdT, DataT> Freeze for NodeList<BackendT, ContextT, ErrorT, IdT, DataT>
impl<BackendT, ContextT, ErrorT, IdT, DataT> RefUnwindSafe for NodeList<BackendT, ContextT, ErrorT, IdT, DataT>where
IdT: RefUnwindSafe,
DataT: RefUnwindSafe,
BackendT: RefUnwindSafe,
ContextT: RefUnwindSafe,
ErrorT: RefUnwindSafe,
impl<BackendT, ContextT, ErrorT, IdT, DataT> Send for NodeList<BackendT, ContextT, ErrorT, IdT, DataT>
impl<BackendT, ContextT, ErrorT, IdT, DataT> Sync for NodeList<BackendT, ContextT, ErrorT, IdT, DataT>
impl<BackendT, ContextT, ErrorT, IdT, DataT> Unpin for NodeList<BackendT, ContextT, ErrorT, IdT, DataT>
impl<BackendT, ContextT, ErrorT, IdT, DataT> UnsafeUnpin for NodeList<BackendT, ContextT, ErrorT, IdT, DataT>
impl<BackendT, ContextT, ErrorT, IdT, DataT> UnwindSafe for NodeList<BackendT, ContextT, ErrorT, IdT, DataT>where
IdT: UnwindSafe,
DataT: UnwindSafe,
BackendT: UnwindSafe,
ContextT: UnwindSafe,
ErrorT: UnwindSafe,
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