SourceCacheEx
trait · ferroui-dynamic-data · v0.5.0
trait SourceCacheEx<T: Clone + 'static, K: Eq + Hash + Clone + 'static>: IObservableCache<T, K>
The operators and edit conveniences of caches (SourceCacheEx, and the extension methods of
ObservableCacheEx on IObservableCache and ISourceCache).
Members
cast_cacheadd_or_updateadd_or_update_with_compareradd_or_update_itemsadd_or_update_items_with_comparercleardefer_until_loadededit_diffexpire_afterexpire_after_onexpire_after_with_pollingexpire_after_with_polling_onlimit_size_tolimit_size_to_onpopulate_frompopulate_from_manyrefreshrefresh_itemsrefresh_allremoveremove_itemsremove_keyremove_keyswatch_value
cast_cache
fn cast_cache<U: Clone + 'static>(self: &Self, converter: impl Fn(&T) -> U + 'static) -> Rc<dyn ferroui_system::IObservable<ChangeSet<U, K>>>
The items and their changes, each item converted by converter
(Cast(IObservableCache<TSource, TKey>, Func<TSource, TDestination>)).
add_or_update
fn add_or_update(self: &Self, item: T)
where Self: crate::cache::ISourceCache<T, K>
Adds item, or replaces the item of its key (AddOrUpdate(TObject)).
add_or_update_with_comparer
fn add_or_update_with_comparer(self: &Self, item: T, equality_comparer: impl Fn(&T, &T) -> bool)
where Self: crate::cache::ISourceCache<T, K>
add_or_update that leaves an equal item, by equality_comparer,
as it is (AddOrUpdate(TObject, IEqualityComparer<TObject>)).
add_or_update_items
fn add_or_update_items(self: &Self, items: impl IntoIterator<Item = T>)
where Self: crate::cache::ISourceCache<T, K>
Adds the items, or replaces the items of their keys (AddOrUpdate(IEnumerable<TObject>)).
add_or_update_items_with_comparer
fn add_or_update_items_with_comparer(self: &Self, items: impl IntoIterator<Item = T>, equality_comparer: impl Fn(&T, &T) -> bool)
where Self: crate::cache::ISourceCache<T, K>
add_or_update_items that leaves the equal items, by
equality_comparer, as they are (AddOrUpdate(IEnumerable<TObject>, IEqualityComparer<TObject>)).
clear
fn clear(self: &Self)
where Self: crate::cache::ISourceCache<T, K>
Removes every item (Clear(ISourceCache)).
defer_until_loaded
fn defer_until_loaded(self: &Self) -> std::rc::Rc<dyn ferroui_system::IObservable<crate::cache::ChangeSet<T, K>>>
The items and their changes once the cache has items (DeferUntilLoaded(IObservableCache)).
edit_diff
fn edit_diff(self: &Self, all_items: impl IntoIterator<Item = T>, are_items_equal: impl Fn(&T, &T) -> bool)
where Self: crate::cache::ISourceCache<T, K>
Makes the cache hold all_items with the fewest changes: the items whose keys are gone
are removed, the new keys added, and the items that are_items_equal says differ updated
(EditDiff(IEnumerable<TObject>, Func<TObject, TObject, bool>) and
EditDiff(IEnumerable<TObject>, IEqualityComparer<TObject>)).
expire_after
fn expire_after(self: &Self, time_selector: impl Fn(&T) -> Option<std::time::Duration> + 'static) -> std::rc::Rc<dyn ferroui_system::IObservable<Vec<(K, T)>>>
where Self: crate::cache::ISourceCache<T, K> + Clone + Sized + 'static
Removes each item from the cache once the time that time_selector gives for it has
passed (None: never), timed on the default scheduler; the removed items with their keys
(ExpireAfter(ISourceCache, Func<TObject, TimeSpan?>, TimeSpan? = null, IScheduler? = null)).
expire_after_on
fn expire_after_on(self: &Self, time_selector: impl Fn(&T) -> Option<std::time::Duration> + 'static, scheduler: std::rc::Rc<dyn ferroui_reactive::concurrency::IScheduler>) -> std::rc::Rc<dyn ferroui_system::IObservable<Vec<(K, T)>>>
where Self: crate::cache::ISourceCache<T, K> + Clone + Sized + 'static
expire_after on scheduler.
expire_after_with_polling
fn expire_after_with_polling(self: &Self, time_selector: impl Fn(&T) -> Option<std::time::Duration> + 'static, polling_interval: Option<std::time::Duration>) -> std::rc::Rc<dyn ferroui_system::IObservable<Vec<(K, T)>>>
where Self: crate::cache::ISourceCache<T, K> + Clone + Sized + 'static
expire_after that removes the expired items every
polling_interval rather than at their times.
expire_after_with_polling_on
fn expire_after_with_polling_on(self: &Self, time_selector: impl Fn(&T) -> Option<std::time::Duration> + 'static, polling_interval: Option<std::time::Duration>, scheduler: std::rc::Rc<dyn ferroui_reactive::concurrency::IScheduler>) -> std::rc::Rc<dyn ferroui_system::IObservable<Vec<(K, T)>>>
where Self: crate::cache::ISourceCache<T, K> + Clone + Sized + 'static
expire_after_with_polling on scheduler.
limit_size_to
fn limit_size_to(self: &Self, size_limit: usize) -> std::rc::Rc<dyn ferroui_system::IObservable<Vec<(K, T)>>>
where Self: crate::cache::ISourceCache<T, K> + Clone + Sized + 'static
Removes the oldest items of the cache beyond size_limit, on the default scheduler; the
removed items with their keys (LimitSizeTo(ISourceCache, int, IScheduler? = null)).
Panics
For a size of zero (ArgumentException).
limit_size_to_on
fn limit_size_to_on(self: &Self, size_limit: usize, scheduler: std::rc::Rc<dyn ferroui_reactive::concurrency::IScheduler>) -> std::rc::Rc<dyn ferroui_system::IObservable<Vec<(K, T)>>>
where Self: crate::cache::ISourceCache<T, K> + Clone + Sized + 'static
limit_size_to on scheduler (LimitSizeTo(ISourceCache, int, IScheduler)).
populate_from
fn populate_from(self: &Self, observable: std::rc::Rc<dyn ferroui_system::IObservable<T>>) -> std::rc::Rc<dyn ferroui_system::IDisposable>
where Self: crate::cache::ISourceCache<T, K> + Clone + Sized + 'static
Adds or updates each item of observable (PopulateFrom(IObservable<TObject>)).
populate_from_many
fn populate_from_many<I: IntoIterator<Item = T> + 'static>(self: &Self, observable: std::rc::Rc<dyn ferroui_system::IObservable<I>>) -> std::rc::Rc<dyn ferroui_system::IDisposable>
where Self: crate::cache::ISourceCache<T, K> + Clone + Sized + 'static
Adds or updates the items of each collection of observable
(PopulateFrom(IObservable<IEnumerable<TObject>>)).
refresh
fn refresh(self: &Self, item: &T)
where Self: crate::cache::ISourceCache<T, K>
Signals that item has changed (Refresh(TObject)).
refresh_items
fn refresh_items(self: &Self, items: impl IntoIterator<Item = T>)
where Self: crate::cache::ISourceCache<T, K>
Signals that the items have changed (Refresh(IEnumerable<TObject>)).
refresh_all
fn refresh_all(self: &Self)
where Self: crate::cache::ISourceCache<T, K>
Signals that every item has changed (Refresh()).
remove
fn remove(self: &Self, item: &T)
where Self: crate::cache::ISourceCache<T, K>
Removes the item of the key of item (Remove(TObject)).
remove_items
fn remove_items(self: &Self, items: impl IntoIterator<Item = T>)
where Self: crate::cache::ISourceCache<T, K>
Removes the items of the keys of items (Remove(IEnumerable<TObject>)).
remove_key
fn remove_key(self: &Self, key: K)
where Self: crate::cache::ISourceCache<T, K>
Removes the item of key (RemoveKey(TKey), and Remove(TKey)).
remove_keys
fn remove_keys(self: &Self, keys: impl IntoIterator<Item = K>)
where Self: crate::cache::ISourceCache<T, K>
Removes the items of keys (RemoveKeys(IEnumerable<TKey>), and
Remove(IEnumerable<TKey>)).
watch_value
fn watch_value(self: &Self, key: K) -> std::rc::Rc<dyn ferroui_system::IObservable<T>>
The item of key each time it changes (WatchValue(IObservableCache, TKey)).
Trait implementations
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.