pub struct Tree<T: TreeItem> {
pub nodes: Vec<TreeNode>,
pub items: HashMap<Uuid, TreeIndex<T>>,
path_to_node: HashMap<Vec<String>, usize>,
}
Fields§
§nodes: Vec<TreeNode>
§items: HashMap<Uuid, TreeIndex<T>>
§path_to_node: HashMap<Vec<String>, usize>
Implementations§
Source§impl<T: TreeItem> Tree<T>
impl<T: TreeItem> Tree<T>
Sourcepub fn from_items(items: Vec<T>) -> Self
pub fn from_items(items: Vec<T>) -> Self
Takes vector of TreeItem and stores them into a tree structure.
Sourcefn add_item(&mut self, index: TreeIndex<T>)
fn add_item(&mut self, index: TreeIndex<T>)
This inserts an item into the tree and sets any look-up information that may be needed.
Sourcepub fn get_item_by_id(&self, tree_item_id: Uuid) -> Option<NodeItem<T>>
pub fn get_item_by_id(&self, tree_item_id: Uuid) -> Option<NodeItem<T>>
Returns an optional node item for a given tree item id.
This contains the item, its children (or an empty vector), and its parent (if it has one)
fn get_relatives(&self, item: &TreeIndex<T>) -> Option<NodeItem<T>>
Sourcepub fn get_root_items(&self) -> Vec<NodeItem<T>>
pub fn get_root_items(&self) -> Vec<NodeItem<T>>
Returns the list of root nodes with their children
Sourcepub fn get_flat_items(&self) -> Vec<NodeItem<T>>
pub fn get_flat_items(&self) -> Vec<NodeItem<T>>
Returns a flat list of all items in the tree with relationships.
Auto Trait Implementations§
impl<T> Freeze for Tree<T>
impl<T> RefUnwindSafe for Tree<T>where
T: RefUnwindSafe,
impl<T> Send for Tree<T>where
T: Send,
impl<T> Sync for Tree<T>where
T: Sync,
impl<T> Unpin for Tree<T>where
T: Unpin,
impl<T> UnwindSafe for Tree<T>where
T: 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
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
§fn new_handle(value: Arc<T>) -> Handle
fn new_handle(value: Arc<T>) -> Handle
Create a new handle for an Arc value Read more
§unsafe fn clone_handle(handle: Handle) -> Handle
unsafe fn clone_handle(handle: Handle) -> Handle
Clone a handle Read more
§unsafe fn consume_handle(handle: Handle) -> Arc<T>
unsafe fn consume_handle(handle: Handle) -> Arc<T>
Consume a handle, getting back the initial
Arc<>
Read more§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more