Struct promkit::tree::Tree

source ·
pub struct Tree { /* private fields */ }
Expand description

A Tree structure that manages a collection of nodes in a hierarchical manner. It utilizes a cursor to navigate and manipulate the nodes within the tree.

Implementations§

source§

impl Tree

source

pub fn new(root: Node) -> Self

Creates a new Tree with a given root node.

§Arguments
  • root - The root node of the tree.
source

pub fn kinds(&self) -> Vec<Kind>

Returns a vector of all nodes in the tree, represented with their depth information.

source

pub fn position(&self) -> usize

Returns the current position of the cursor within the tree.

source

pub fn get(&self) -> Vec<String>

Retrieves the data of the current node pointed by the cursor, along with its path from the root.

source

pub fn toggle(&mut self)

Toggles the state of the current node and updates the cursor position accordingly.

source

pub fn backward(&mut self) -> bool

Moves the cursor backward in the tree, if possible.

Returns true if the cursor was successfully moved backward, false otherwise.

source

pub fn forward(&mut self) -> bool

Moves the cursor forward in the tree, if possible.

Returns true if the cursor was successfully moved forward, false otherwise.

source

pub fn move_to_head(&mut self)

Moves the cursor to the head of the tree.

source

pub fn move_to_tail(&mut self)

Moves the cursor to the tail of the tree.

Trait Implementations§

source§

impl Clone for Tree

source§

fn clone(&self) -> Tree

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl Freeze for Tree

§

impl RefUnwindSafe for Tree

§

impl Send for Tree

§

impl Sync for Tree

§

impl Unpin for Tree

§

impl UnwindSafe for Tree

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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.