i_slint_core::properties

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

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.