Skip to main content

Conditional

Struct Conditional 

Source
pub struct Conditional<C: RepeatedItemTree> { /* private fields */ }

Implementations§

Source§

impl<C: RepeatedItemTree + 'static> Conditional<C>

Source

pub fn track_model_changes(self: Pin<&Self>)

Register the condition as a dependency of the current tracking scope (e.g. the redraw tracker) so it is notified when the condition changes.

Source

pub fn track_instance_changes(self: Pin<&Self>)

Register the instance generation as a dependency of the current tracking scope. Layout code uses this to re-evaluate only after ensure_updated materializes instance changes.

Source

pub fn ensure_updated( self: Pin<&Self>, init: impl Fn() -> VRc<ItemTreeVTable, C>, ) -> bool

Call this function to make sure that the model is updated. The init function is the function to create a ItemTree. Returns true if the instance was created or removed, or any child changed.

Source

pub fn set_model_binding(&self, binding: impl Fn() -> bool + 'static)

Set the model binding

Source

pub fn visit( self: Pin<&Self>, order: TraversalOrder, visitor: ItemVisitorRefMut<'_>, ) -> VisitChildrenResult

Call the visitor for the root of each instance. Also registers model dependencies so the current tracking scope (e.g. the redraw tracker) is notified when the condition changes.

Source

pub fn len(&self) -> usize

Return the amount of instances (1 if the conditional is active, 0 otherwise)

Source

pub fn range(&self) -> Range<usize>

Return the range of indices used by this Conditional.

Similar to Repeater::range, but the range is always [0, 1] if the Conditional is active.

Source

pub fn instance_at(&self, index: usize) -> Option<VRc<ItemTreeVTable, C>>

Return the instance for the given model index. The index should be within Self::range()

Source

pub fn is_empty(&self) -> bool

Return true if the Repeater as empty

Source

pub fn instances_vec(&self) -> Vec<VRc<ItemTreeVTable, C>>

Returns a vector containing all instances

Trait Implementations§

Source§

impl<C: RepeatedItemTree> Default for Conditional<C>

Source§

fn default() -> Self

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

impl<'pin, C: RepeatedItemTree> Unpin for Conditional<C>
where PinnedFieldsOf<__Conditional<'pin, C>>: Unpin,

Auto Trait Implementations§

§

impl<C> !Freeze for Conditional<C>

§

impl<C> !RefUnwindSafe for Conditional<C>

§

impl<C> !Send for Conditional<C>

§

impl<C> !Sync for Conditional<C>

§

impl<C> !UnsafeUnpin for Conditional<C>

§

impl<C> UnwindSafe for Conditional<C>
where C: RefUnwindSafe,

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> ErasedDestructor for T
where T: 'static,

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.