Skip to main content

TreeNode

Struct TreeNode 

pub struct TreeNode<T> {
    pub id: u64,
    pub label: String,
    pub data: T,
    pub children: Vec<TreeNode<T>>,
    /* private fields */
}

Fields§

§id: u64§label: String§data: T§children: Vec<TreeNode<T>>

Implementations§

§

impl<T> TreeNode<T>

pub fn leaf(id: u64, label: impl Into<String>, data: T) -> TreeNode<T>

pub fn branch( id: u64, label: impl Into<String>, data: T, children: Vec<TreeNode<T>>, ) -> TreeNode<T>

A branch with zero children still renders the disclosure glyph, so callers can populate it (e.g. an empty folder) later.

pub fn is_branch(&self) -> bool

pub fn find(&self, id: u64) -> Option<&TreeNode<T>>

pub fn find_mut(&mut self, id: u64) -> Option<&mut TreeNode<T>>

pub fn can_reorder(&self, source: u64, target: &DropTarget<u64>) -> bool

Whether an owned node can be moved to this stable drop target.

Root moves, self-drops, drops inside leaves, and moves that would put a node below one of its own descendants are rejected. Apps with further domain constraints can combine this with TreeView::with_reorder.

pub fn reorder(&mut self, dropped: &ReorderDrop<u64>) -> bool

Apply a validated before/inside/after move to this owned hierarchy.

The complete source subtree is preserved. Indices are resolved again after detaching the source, so sibling moves cannot suffer the usual off-by-one error. Moving a node to its current position returns false without mutating the hierarchy.

Trait Implementations§

§

impl<T> TreeModel for TreeNode<T>

§

fn root_id(&self) -> u64

§

fn contains(&self, id: u64) -> bool

§

fn label(&self, id: u64) -> Option<&str>

§

fn is_branch(&self, id: u64) -> bool

§

fn parent_id(&self, id: u64) -> Option<u64>

Parent of id; None only for the root or an unknown id.
§

fn child_index(&self, parent: u64, child: u64) -> Option<usize>

Position of a direct child. Large/paged models should answer this from an index rather than scanning siblings.
§

fn child_count(&self, parent: u64) -> usize

§

fn child_id(&self, parent: u64, index: usize) -> Option<u64>

§

fn accepts_children(&self, id: u64) -> bool

Whether a drop or an indent may make id a parent. Defaults to Self::is_branch; a hierarchy where any node can hold children (an outline, a notebook) answers true for leaves too, while Self::is_branch keeps deciding which rows show a disclosure.
§

fn semantic_key(&self, _id: u64) -> Option<String>

A durable identity for id in the semantic tree ("notes:page:<uuid>"), for models whose node ids are only stable within a session. Assistive technology and automation then address the row by it across launches.
§

fn is_selectable(&self, _id: u64) -> bool

Whether id can be chosen. A row that cannot (a section header in a navigation list) still takes focus and expands, but is never selected or activated.
§

fn is_renamable(&self, _id: u64) -> bool

Whether id’s label can be edited in place (see TreeView::on_rename).
§

fn shows_row_actions(&self, _id: u64) -> bool

Whether id’s row shows the tree’s row actions on hover and focus.
§

fn can_collapse(&self, _id: u64) -> bool

Whether an expanded branch may be collapsed. A heading whose rows are always shown answers false.
§

fn child_state(&self, parent: u64, index: usize) -> TreeChildState<'_>

Resolve a logical child slot. Paged models override this to return TreeChildState::Loading or TreeChildState::Error for non-resident rows; existing fully-resident models need only implement Self::child_id.
§

fn request_load(&mut self, _request: TreeLoadRequest) -> bool

Start or deduplicate work for one visible/retried child slot. Return whether the model accepted the request. Model-owned asynchronous sources can complete through Self::poll_changes; external owners may instead use TreeView::on_load_request.
§

fn poll_changes(&mut self) -> Vec<TreeModelChange>

Drain model-owned structural, row-data, or slot-state changes.
§

fn needs_poll(&self) -> bool

Keep scheduling frames only for sources that cannot wake the app when a batch completes. Prefer crate::LatestRequest for idle workers.

Auto Trait Implementations§

§

impl<T> Freeze for TreeNode<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for TreeNode<T>
where T: RefUnwindSafe,

§

impl<T> Send for TreeNode<T>
where T: Send,

§

impl<T> Sync for TreeNode<T>
where T: Sync,

§

impl<T> Unpin for TreeNode<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for TreeNode<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for TreeNode<T>
where T: 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
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

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> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

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
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> Fruit for T
where T: Send + Downcast,

§

impl<T> MaybeSendSync for T
where T: Send + Sync + ?Sized,

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T

§

impl<T> WasmNotSync for T
where T: Sync,