logo
pub struct ItemCache<T> { /* private fields */ }
Expand description

A per-item cache.

Cache rendering information for a given item.

Use ItemCache::get_or_update_cache_entry to get or update the items, the cache is automatically invalided when the property gets dirty. ItemCache::component_destroyed must be called to clear the cache for that component.

Implementations

source

pub fn get_or_update_cache_entry(
    &self,
    item_rc: &ItemRc,
    update_fn: impl FnOnce() -> T
) -> T

Returns the cached value associated to the item_rc if it is still valid. Otherwise call the update_fn to compute that value, and track property access so it is automatically invalided when property becomes dirty.

free the whole cache

Function that must be called when a component is destroyed.

Usually can be called from crate::window::PlatformWindow::unregister_component

free the cache for a given item

Trait Implementations

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.