Skip to main content

TreeState

Struct TreeState 

Source
pub struct TreeState<K: Key> { /* private fields */ }
Expand description

A tree’s state between passes: the cache, the selection, where it is scrolled.

Implementations§

Source§

impl<K: Key> TreeState<K>

Source

pub fn new() -> Self

Source

pub fn handle(&self) -> TreeHandle<K>

The application’s hand on the view: edits from any thread.

Source

pub fn selection(&self) -> &Selection<K>

Source

pub fn set_selection( &mut self, keys: impl IntoIterator<Item = K>, cursor: Option<K>, )

Sets the selection without running a step (restoring a saved state, following another view). Nodes the view has not loaded yet (under a branch not opened, or still loading) are queued: the selection takes each as it loads, and once all have come the cursor’s row is brought into view. Open their ancestors (TreeState::set_expanded) so that they load. The user selecting, or another call, drops what was queued.

Source

pub fn pending_selection(&self) -> Option<(&[K], Option<&K>)>

The selection queued by TreeState::set_selection for nodes not loaded yet.

Source

pub fn model(&self) -> &Model<K>

What the view knows: nodes, children, expansion, rows.

Source

pub fn set_expanded(&mut self, key: &K, expanded: bool)

Opens or closes a branch without running a step (restoring a saved state).

Source

pub fn rename(&mut self, key: &K)

Starts renaming a node in place, from its plain name (Node::name).

Source

pub fn reveal(&mut self, key: &K)

Brings a node’s row into view at the next pass, if its row is there by then (open its ancestors first).

Source

pub fn set_filter(&mut self, text: impl Into<String>)

Filters the tree (empty: no filter), from its next draw: the nodes matching every word (the filter says how) show with their ancestors, the rest is hidden, and the cursor goes to the first match when its row hides. A FilterField types it.

Source

pub fn filter(&self) -> &str

The filter as typed.

Source

pub fn filter_count(&self) -> Option<(usize, usize)>

While the tree filters: how many nodes match, and how many it has loaded.

Source

pub fn renaming(&self) -> Option<&K>

Whether a node is being renamed.

Source

pub fn dropped(&self) -> u64

Edits dropped since the tree was made: they waited past EDITS_WAITING while the tree was not drawn, and every branch was loaded again instead.

Source

pub fn waiting(&self) -> usize

Edits waiting for the next pass (at most EDITS_WAITING).

Trait Implementations§

Source§

impl<K: Key> Debug for TreeState<K>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<K: Key> Default for TreeState<K>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<K> Freeze for TreeState<K>
where K: Freeze,

§

impl<K> RefUnwindSafe for TreeState<K>
where K: RefUnwindSafe,

§

impl<K> Send for TreeState<K>
where K: Send,

§

impl<K> Sync for TreeState<K>
where K: Sync + Send,

§

impl<K> Unpin for TreeState<K>
where K: Unpin,

§

impl<K> UnsafeUnpin for TreeState<K>
where K: UnsafeUnpin,

§

impl<K> UnwindSafe for TreeState<K>
where K: 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 + Sync + Send>

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> NoneValue for T
where T: Default,

§

type NoneType = T

§

fn null_value() -> T

The none-equivalent value.
§

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<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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

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

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

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