Skip to main content

TreeModel

Struct TreeModel 

Source
pub struct TreeModel<BackendT, ContextT, ErrorT, IdT, DataT> {
    pub roots: NodeList<BackendT, ContextT, ErrorT, IdT, DataT>,
    pub context: ContextT,
    /* private fields */
}
Expand description

Tree model.

Fields§

§roots: NodeList<BackendT, ContextT, ErrorT, IdT, DataT>

Roots.

§context: ContextT

Context.

Implementations§

Source§

impl<BackendT, ContextT, ErrorT, IdT, DataT> TreeModel<BackendT, ContextT, ErrorT, IdT, DataT>

Source

pub fn new(context: ContextT) -> Self

Constructor.

Source

pub fn is_empty(&self) -> bool

Whether we have no nodes.

Source

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.

Source

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.

Source

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.

Source

pub fn at_row( &self, row: usize, ) -> Option<&Node<BackendT, ContextT, ErrorT, IdT, DataT>>
where DataT: 'static,

Get node at row.

Source

pub fn path( &self, node: &Node<BackendT, ContextT, ErrorT, IdT, DataT>, ) -> Option<NodePath>
where BackendT: TreeBackend<ContextT, ErrorT, IdT, DataT>,

Find path to node.

Source

pub fn size(&self) -> XY<usize>
where DataT: 'static,

Size.

Source

pub fn add_root( &mut self, kind: NodeKind, id: IdT, representation: Representation, )
where BackendT: TreeBackend<ContextT, ErrorT, IdT, DataT>,

Add a root node.

Source

pub fn insert_root( &mut self, index: usize, kind: NodeKind, id: IdT, representation: Representation, )
where BackendT: TreeBackend<ContextT, ErrorT, IdT, DataT>,

Insert a root node.

Source

pub fn populate(&mut self, depth: Option<usize>) -> Result<(), ErrorT>
where BackendT: TreeBackend<ContextT, ErrorT, IdT, DataT>, ContextT: Clone,

Fetch nodes from backend.

If depth is None will populate the entire tree.

If depth is 0 will do nothing.

Source

pub fn clear(&mut self)

Remove all nodes.

Trait Implementations§

Source§

impl<BackendT, ContextT, ErrorT, IdT, DataT> From<TreeModel<BackendT, ContextT, ErrorT, IdT, DataT>> for TreeView<BackendT, ContextT, ErrorT, IdT, DataT>

Source§

fn from(model: TreeModel<BackendT, ContextT, ErrorT, IdT, DataT>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<BackendT, ContextT, ErrorT, IdT, DataT> Freeze for TreeModel<BackendT, ContextT, ErrorT, IdT, DataT>
where ContextT: Freeze,

§

impl<BackendT, ContextT, ErrorT, IdT, DataT> RefUnwindSafe for TreeModel<BackendT, ContextT, ErrorT, IdT, DataT>
where ContextT: RefUnwindSafe, BackendT: RefUnwindSafe, ErrorT: RefUnwindSafe, IdT: RefUnwindSafe, DataT: RefUnwindSafe,

§

impl<BackendT, ContextT, ErrorT, IdT, DataT> Send for TreeModel<BackendT, ContextT, ErrorT, IdT, DataT>
where ContextT: Send, BackendT: Send, ErrorT: Send, IdT: Send, DataT: Send,

§

impl<BackendT, ContextT, ErrorT, IdT, DataT> Sync for TreeModel<BackendT, ContextT, ErrorT, IdT, DataT>
where ContextT: Sync, BackendT: Sync, ErrorT: Sync, IdT: Sync, DataT: Sync,

§

impl<BackendT, ContextT, ErrorT, IdT, DataT> Unpin for TreeModel<BackendT, ContextT, ErrorT, IdT, DataT>
where ContextT: Unpin, BackendT: Unpin, ErrorT: Unpin, IdT: Unpin, DataT: Unpin,

§

impl<BackendT, ContextT, ErrorT, IdT, DataT> UnsafeUnpin for TreeModel<BackendT, ContextT, ErrorT, IdT, DataT>
where ContextT: UnsafeUnpin,

§

impl<BackendT, ContextT, ErrorT, IdT, DataT> UnwindSafe for TreeModel<BackendT, ContextT, ErrorT, IdT, DataT>
where ContextT: UnwindSafe, BackendT: UnwindSafe, ErrorT: UnwindSafe, IdT: UnwindSafe, DataT: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> With for T

Source§

fn wrap_with<U, F>(self, f: F) -> U
where F: FnOnce(Self) -> U,

Calls the given closure and return the result. Read more
Source§

fn with<F>(self, f: F) -> Self
where F: FnOnce(&mut Self),

Calls the given closure on self.
Source§

fn try_with<E, F>(self, f: F) -> Result<Self, E>
where F: FnOnce(&mut Self) -> Result<(), E>,

Calls the given closure on self.
Source§

fn with_if<F>(self, condition: bool, f: F) -> Self
where F: FnOnce(&mut Self),

Calls the given closure if condition == true.