Struct Tree

pub struct Tree<I>
where I: GenerationalId,
{ pub parent: Vec<Option<I>>, pub first_child: Vec<Option<I>>, pub next_sibling: Vec<Option<I>>, pub prev_sibling: Vec<Option<I>>, pub ignored: Vec<bool>, pub window: Vec<bool>, pub lock_focus_within: Vec<bool>, pub changed: bool, }
Expand description

The Tree describes the tree of entities.

Fields§

§parent: Vec<Option<I>>§first_child: Vec<Option<I>>§next_sibling: Vec<Option<I>>§prev_sibling: Vec<Option<I>>§ignored: Vec<bool>§window: Vec<bool>§lock_focus_within: Vec<bool>§changed: bool

Implementations§

§

impl<I> Tree<I>
where I: GenerationalId,

pub fn new() -> Tree<I>

Creates a new tree with a root entity.

pub fn get_child_index(&self, entity: I) -> Option<usize>

pub fn get_last_child(&self, entity: I) -> Option<&I>

Returns the last child of an entity.

pub fn get_child(&self, entity: I, n: usize) -> Option<I>

Returns the nth child of an entity.

pub fn get_num_children(&self, entity: I) -> Option<u32>

Returns the number of children of an entity.

pub fn is_ignored(&self, entity: I) -> bool

Returns true if the node should be skipped by layout

pub fn is_window(&self, entity: I) -> bool

Returns true if the node should be skipped by layout

pub fn lock_focus_within(&self, entity: I) -> I

Returns the first ancestor to have the lock_focus_within flag set

pub fn get_layout_parent(&self, entity: I) -> Option<I>

Returns the first ancestor of an entity which is not ignored

pub fn get_parent(&self, entity: I) -> Option<I>

Returns the parent of an entity.

pub fn get_parent_window(&self, entity: I) -> Option<I>

pub fn get_first_child(&self, entity: I) -> Option<I>

Returns the first child of an entity or None if there isn’t one.

pub fn get_layout_first_child(&self, entity: I) -> Option<I>

pub fn get_next_sibling(&self, entity: I) -> Option<I>

Returns the next sibling of an entity or None if t here isn’t one.

pub fn get_next_layout_sibling(&self, entity: I) -> Option<I>

Returns the next layout sibling of an entity or None if t here isn’t one.

pub fn get_prev_sibling(&self, entity: I) -> Option<I>

Returns the previous sibling of an entity or None if there isn’t one.

pub fn get_prev_layout_sibling(&self, entity: I) -> Option<I>

Returns the previous layout sibling of an entity or None if there isn’t one.

pub fn is_first_child(&self, entity: I) -> bool

Returns true if the entity is the first child of its parent.

pub fn is_last_child(&self, entity: I) -> bool

Returns true if the entity is the last child of its parent.

pub fn is_sibling(&self, entity1: I, entity2: I) -> bool

pub fn has_children(&self, entity: I) -> bool

Returns true if the entity has children.

pub fn remove(&mut self, entity: I) -> Result<(), TreeError>

Removes an entity from the tree

This method assumes that a check if the entity is alive has already been done prior to calling this method.

pub fn set_first_child(&mut self, entity: I) -> Result<(), TreeError>

Makes the entity the first child of its parent.

pub fn set_next_sibling( &mut self, entity: I, sibling: I, ) -> Result<(), TreeError>

pub fn set_prev_sibling( &mut self, entity: I, sibling: I, ) -> Result<(), TreeError>

pub fn set_parent(&mut self, entity: I, parent: I)

pub fn set_ignored(&mut self, entity: I, flag: bool)

pub fn set_window(&mut self, entity: I, flag: bool)

pub fn set_lock_focus_within(&mut self, entity: I, flag: bool)

pub fn add(&mut self, entity: I, parent: I) -> Result<(), TreeError>

Adds an entity to the tree with the specified parent.

Trait Implementations§

§

impl<I> Clone for Tree<I>
where I: Clone + GenerationalId,

§

fn clone(&self) -> Tree<I>

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
§

impl<I> Debug for Tree<I>
where I: Debug + GenerationalId,

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl<'a, I> IntoIterator for &'a Tree<I>
where I: GenerationalId,

§

type Item = I

The type of the elements being iterated over.
§

type IntoIter = TreeIterator<'a, I>

Which kind of iterator are we turning this into?
§

fn into_iter(self) -> <&'a Tree<I> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<I> Freeze for Tree<I>

§

impl<I> RefUnwindSafe for Tree<I>
where I: RefUnwindSafe,

§

impl<I> Send for Tree<I>
where I: Send,

§

impl<I> Sync for Tree<I>
where I: Sync,

§

impl<I> Unpin for Tree<I>
where I: Unpin,

§

impl<I> UnwindSafe for Tree<I>
where I: 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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,

Source§

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

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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more