Struct i_slint_core::properties::PropertyTracker

source ·
pub struct PropertyTracker<DirtyHandler = ()> { /* private fields */ }
Expand description

This structure allow to run a closure that queries properties, and can report if any property we accessed have become dirty

Implementations§

source§

impl<DirtyHandler: PropertyDirtyHandler> PropertyTracker<DirtyHandler>

source

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

Register this property tracker as a dependency to the current binding/property tracker being evaluated

source

pub fn is_dirty(&self) -> bool

Any of the properties accessed during the last evaluation of the closure called from the last call to evaluate is potentially dirty.

source

pub fn evaluate<R>(self: Pin<&Self>, f: impl FnOnce() -> R) -> R

Evaluate the function, and record dependencies of properties accessed within this function. If this is called during the evaluation of another property binding or property tracker, then any changes to accessed properties will also mark the other binding/tracker dirty.

source

pub fn evaluate_as_dependency_root<R>( self: Pin<&Self>, f: impl FnOnce() -> R ) -> R

Evaluate the function, and record dependencies of properties accessed within this function. If this is called during the evaluation of another property binding or property tracker, then any changes to accessed properties will not propagate to the other tracker.

source

pub fn evaluate_if_dirty<R>( self: Pin<&Self>, f: impl FnOnce() -> R ) -> Option<R>

Call Self::evaluate if and only if it is dirty. But register a dependency in any case.

source

pub fn set_dirty(&self)

Mark this PropertyTracker as dirty

source

pub fn new_with_dirty_handler(handler: DirtyHandler) -> Self

Sets the specified callback handler function, which will be called if any properties that this tracker depends on becomes dirty.

The handler PropertyDirtyHandler is a trait which is implemented for any Fn() closure

Note that the handler will be invoked immediately when a property is modified or marked as dirty. In particular, the involved property are still in a locked state and should not be accessed while the handler is run. This function can be useful to mark some work to be done later.

Trait Implementations§

source§

impl Default for PropertyTracker<()>

source§

fn default() -> Self

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

impl<DirtyHandler> Drop for PropertyTracker<DirtyHandler>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<DirtyHandler = ()> !Freeze for PropertyTracker<DirtyHandler>

§

impl<DirtyHandler = ()> !RefUnwindSafe for PropertyTracker<DirtyHandler>

§

impl<DirtyHandler = ()> !Send for PropertyTracker<DirtyHandler>

§

impl<DirtyHandler = ()> !Sync for PropertyTracker<DirtyHandler>

§

impl<DirtyHandler = ()> !Unpin for PropertyTracker<DirtyHandler>

§

impl<DirtyHandler = ()> !UnwindSafe for PropertyTracker<DirtyHandler>

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