pub struct IntermediateCache<T, K> { /* private fields */ }Expand description
A cache without a key selector, whose edits give the keys (IntermediateCache<TObject, TKey>): the cache of the operators that keep items under keys of their own. A clone is a
handle to the same cache.
Implementations§
Source§impl<T: Clone + 'static, K: Eq + Hash + Clone + 'static> IntermediateCache<T, K>
impl<T: Clone + 'static, K: Eq + Hash + Clone + 'static> IntermediateCache<T, K>
Sourcepub fn from_source<C: IChangeSet<T, K>>(source: Rc<dyn IObservable<C>>) -> Self
pub fn from_source<C: IChangeSet<T, K>>(source: Rc<dyn IObservable<C>>) -> Self
A cache that applies the change sets of source (IntermediateCache(IObservable<IChangeSet>)).
Sourcepub fn edit(&self, update: impl FnOnce(&mut dyn ICacheUpdater<T, K>))
pub fn edit(&self, update: impl FnOnce(&mut dyn ICacheUpdater<T, K>))
Runs an edit (Edit(Action<ICacheUpdater>)).
Sourcepub fn suspend_count(&self) -> Rc<dyn IDisposable>
pub fn suspend_count(&self) -> Rc<dyn IDisposable>
Holds back the notifications of count changes until the result is disposed (SuspendCount).
Sourcepub fn suspend_notifications(&self) -> Rc<dyn IDisposable>
pub fn suspend_notifications(&self) -> Rc<dyn IDisposable>
Holds back the notifications of changes until the result is disposed
(SuspendNotifications).
Sourcepub fn add_or_update(&self, item: T, key: K)
pub fn add_or_update(&self, item: T, key: K)
Adds item under key, or replaces the item of key (AddOrUpdate(IIntermediateCache, TObject, TKey)).
Sourcepub fn remove_key(&self, key: K)
pub fn remove_key(&self, key: K)
Removes the item of key (Remove(IIntermediateCache, TKey)).
Sourcepub fn remove_keys(&self, keys: impl IntoIterator<Item = K>)
pub fn remove_keys(&self, keys: impl IntoIterator<Item = K>)
Removes the items of keys (Remove(IIntermediateCache, IEnumerable<TKey>)).
Trait Implementations§
Source§impl<T, K> Clone for IntermediateCache<T, K>
impl<T, K> Clone for IntermediateCache<T, K>
Source§impl<T: Clone + 'static, K: Eq + Hash + Clone + 'static> IConnectableCache<T, K> for IntermediateCache<T, K>
impl<T: Clone + 'static, K: Eq + Hash + Clone + 'static> IConnectableCache<T, K> for IntermediateCache<T, K>
Source§fn count_changed(&self) -> Rc<dyn IObservable<usize>>
fn count_changed(&self) -> Rc<dyn IObservable<usize>>
The number of items, now and whenever it changes (
CountChanged).Source§fn connect_with(
&self,
predicate: Option<Rc<dyn Fn(&T) -> bool>>,
suppress_empty_change_sets: bool,
) -> Rc<dyn IObservable<ChangeSet<T, K>>>
fn connect_with( &self, predicate: Option<Rc<dyn Fn(&T) -> bool>>, suppress_empty_change_sets: bool, ) -> Rc<dyn IObservable<ChangeSet<T, K>>>
The items as additions, then the changes, of the items that
predicate accepts; empty
change sets are left out unless suppress_empty_change_sets is false (Connect).Source§fn preview_with(
&self,
predicate: Option<Rc<dyn Fn(&T) -> bool>>,
) -> Rc<dyn IObservable<ChangeSet<T, K>>>
fn preview_with( &self, predicate: Option<Rc<dyn Fn(&T) -> bool>>, ) -> Rc<dyn IObservable<ChangeSet<T, K>>>
The changes before they are applied, while the items are as they were (
Preview).Source§fn watch(&self, key: K) -> Rc<dyn IObservable<Change<T, K>>>
fn watch(&self, key: K) -> Rc<dyn IObservable<Change<T, K>>>
The changes of the item of
key (Watch).Source§fn connect(&self) -> Rc<dyn IObservable<ChangeSet<T, K>>>
fn connect(&self) -> Rc<dyn IObservable<ChangeSet<T, K>>>
The items and their changes (
Connect()).Source§fn connect_filtered(
&self,
predicate: impl Fn(&T) -> bool + 'static,
) -> Rc<dyn IObservable<ChangeSet<T, K>>>where
Self: Sized,
fn connect_filtered(
&self,
predicate: impl Fn(&T) -> bool + 'static,
) -> Rc<dyn IObservable<ChangeSet<T, K>>>where
Self: Sized,
The items that
predicate accepts and their changes (Connect(Func<TObject, bool>)).Source§impl<T: Clone + 'static, K: Eq + Hash + Clone + 'static> IDisposable for IntermediateCache<T, K>
impl<T: Clone + 'static, K: Eq + Hash + Clone + 'static> IDisposable for IntermediateCache<T, K>
Source§impl<T: Clone + 'static, K: Eq + Hash + Clone + 'static> IIntermediateCache<T, K> for IntermediateCache<T, K>
impl<T: Clone + 'static, K: Eq + Hash + Clone + 'static> IIntermediateCache<T, K> for IntermediateCache<T, K>
Source§fn edit(&self, update: &mut dyn FnMut(&mut dyn ICacheUpdater<T, K>))
fn edit(&self, update: &mut dyn FnMut(&mut dyn ICacheUpdater<T, K>))
Runs an edit; its changes are delivered as one change set when it ends (
Edit).Source§impl<T: Clone + 'static, K: Eq + Hash + Clone + 'static> IObservableCache<T, K> for IntermediateCache<T, K>
impl<T: Clone + 'static, K: Eq + Hash + Clone + 'static> IObservableCache<T, K> for IntermediateCache<T, K>
Source§fn key_values(&self) -> Dictionary<K, T>
fn key_values(&self) -> Dictionary<K, T>
The keys and items (
KeyValues).Auto Trait Implementations§
impl<T, K> !RefUnwindSafe for IntermediateCache<T, K>
impl<T, K> !Send for IntermediateCache<T, K>
impl<T, K> !Sync for IntermediateCache<T, K>
impl<T, K> !UnwindSafe for IntermediateCache<T, K>
impl<T, K> Freeze for IntermediateCache<T, K>where
ObservableCache<T, K>: Freeze,
impl<T, K> Unpin for IntermediateCache<T, K>where
ObservableCache<T, K>: Unpin,
impl<T, K> UnsafeUnpin for IntermediateCache<T, K>where
ObservableCache<T, K>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, K, C> SourceCacheEx<T, K> for C
impl<T, K, C> SourceCacheEx<T, K> for C
Source§fn cast_cache<U: Clone + 'static>(
&self,
converter: impl Fn(&T) -> U + 'static,
) -> Rc<dyn IObservable<ChangeSet<U, K>>>
fn cast_cache<U: Clone + 'static>( &self, converter: impl Fn(&T) -> U + 'static, ) -> Rc<dyn IObservable<ChangeSet<U, K>>>
The items and their changes, each item converted by
converter
(Cast(IObservableCache<TSource, TKey>, Func<TSource, TDestination>)).Source§fn add_or_update(&self, item: T)where
Self: ISourceCache<T, K>,
fn add_or_update(&self, item: T)where
Self: ISourceCache<T, K>,
Adds
item, or replaces the item of its key (AddOrUpdate(TObject)).Source§fn add_or_update_with_comparer(
&self,
item: T,
equality_comparer: impl Fn(&T, &T) -> bool,
)where
Self: ISourceCache<T, K>,
fn add_or_update_with_comparer(
&self,
item: T,
equality_comparer: impl Fn(&T, &T) -> bool,
)where
Self: ISourceCache<T, K>,
add_or_update that leaves an equal item, by equality_comparer,
as it is (AddOrUpdate(TObject, IEqualityComparer<TObject>)).Source§fn add_or_update_items(&self, items: impl IntoIterator<Item = T>)where
Self: ISourceCache<T, K>,
fn add_or_update_items(&self, items: impl IntoIterator<Item = T>)where
Self: ISourceCache<T, K>,
Adds the items, or replaces the items of their keys (
AddOrUpdate(IEnumerable<TObject>)).Source§fn add_or_update_items_with_comparer(
&self,
items: impl IntoIterator<Item = T>,
equality_comparer: impl Fn(&T, &T) -> bool,
)where
Self: ISourceCache<T, K>,
fn add_or_update_items_with_comparer(
&self,
items: impl IntoIterator<Item = T>,
equality_comparer: impl Fn(&T, &T) -> bool,
)where
Self: ISourceCache<T, K>,
add_or_update_items that leaves the equal items, by
equality_comparer, as they are (AddOrUpdate(IEnumerable<TObject>, IEqualityComparer<TObject>)).Source§fn clear(&self)where
Self: ISourceCache<T, K>,
fn clear(&self)where
Self: ISourceCache<T, K>,
Removes every item (
Clear(ISourceCache)).Source§fn defer_until_loaded(&self) -> Rc<dyn IObservable<ChangeSet<T, K>>>
fn defer_until_loaded(&self) -> Rc<dyn IObservable<ChangeSet<T, K>>>
The items and their changes once the cache has items (
DeferUntilLoaded(IObservableCache)).Source§fn edit_diff(
&self,
all_items: impl IntoIterator<Item = T>,
are_items_equal: impl Fn(&T, &T) -> bool,
)where
Self: ISourceCache<T, K>,
fn edit_diff(
&self,
all_items: impl IntoIterator<Item = T>,
are_items_equal: impl Fn(&T, &T) -> bool,
)where
Self: 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>)).Source§fn expire_after(
&self,
time_selector: impl Fn(&T) -> Option<Duration> + 'static,
) -> Rc<dyn IObservable<Vec<(K, T)>>>
fn expire_after( &self, time_selector: impl Fn(&T) -> Option<Duration> + 'static, ) -> Rc<dyn IObservable<Vec<(K, T)>>>
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)).Source§fn expire_after_on(
&self,
time_selector: impl Fn(&T) -> Option<Duration> + 'static,
scheduler: Rc<dyn IScheduler>,
) -> Rc<dyn IObservable<Vec<(K, T)>>>
fn expire_after_on( &self, time_selector: impl Fn(&T) -> Option<Duration> + 'static, scheduler: Rc<dyn IScheduler>, ) -> Rc<dyn IObservable<Vec<(K, T)>>>
expire_after on scheduler.Source§fn expire_after_with_polling(
&self,
time_selector: impl Fn(&T) -> Option<Duration> + 'static,
polling_interval: Option<Duration>,
) -> Rc<dyn IObservable<Vec<(K, T)>>>
fn expire_after_with_polling( &self, time_selector: impl Fn(&T) -> Option<Duration> + 'static, polling_interval: Option<Duration>, ) -> Rc<dyn IObservable<Vec<(K, T)>>>
expire_after that removes the expired items every
polling_interval rather than at their times.Source§fn expire_after_with_polling_on(
&self,
time_selector: impl Fn(&T) -> Option<Duration> + 'static,
polling_interval: Option<Duration>,
scheduler: Rc<dyn IScheduler>,
) -> Rc<dyn IObservable<Vec<(K, T)>>>
fn expire_after_with_polling_on( &self, time_selector: impl Fn(&T) -> Option<Duration> + 'static, polling_interval: Option<Duration>, scheduler: Rc<dyn IScheduler>, ) -> Rc<dyn IObservable<Vec<(K, T)>>>
expire_after_with_polling on scheduler.Source§fn limit_size_to(&self, size_limit: usize) -> Rc<dyn IObservable<Vec<(K, T)>>>
fn limit_size_to(&self, size_limit: usize) -> Rc<dyn IObservable<Vec<(K, T)>>>
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)). Read moreSource§fn limit_size_to_on(
&self,
size_limit: usize,
scheduler: Rc<dyn IScheduler>,
) -> Rc<dyn IObservable<Vec<(K, T)>>>
fn limit_size_to_on( &self, size_limit: usize, scheduler: Rc<dyn IScheduler>, ) -> Rc<dyn IObservable<Vec<(K, T)>>>
Source§fn populate_from(
&self,
observable: Rc<dyn IObservable<T>>,
) -> Rc<dyn IDisposable>
fn populate_from( &self, observable: Rc<dyn IObservable<T>>, ) -> Rc<dyn IDisposable>
Adds or updates each item of
observable (PopulateFrom(IObservable<TObject>)).Source§fn populate_from_many<I: IntoIterator<Item = T> + 'static>(
&self,
observable: Rc<dyn IObservable<I>>,
) -> Rc<dyn IDisposable>
fn populate_from_many<I: IntoIterator<Item = T> + 'static>( &self, observable: Rc<dyn IObservable<I>>, ) -> Rc<dyn IDisposable>
Adds or updates the items of each collection of
observable
(PopulateFrom(IObservable<IEnumerable<TObject>>)).Source§fn refresh(&self, item: &T)where
Self: ISourceCache<T, K>,
fn refresh(&self, item: &T)where
Self: ISourceCache<T, K>,
Signals that
item has changed (Refresh(TObject)).Source§fn refresh_items(&self, items: impl IntoIterator<Item = T>)where
Self: ISourceCache<T, K>,
fn refresh_items(&self, items: impl IntoIterator<Item = T>)where
Self: ISourceCache<T, K>,
Signals that the items have changed (
Refresh(IEnumerable<TObject>)).Source§fn refresh_all(&self)where
Self: ISourceCache<T, K>,
fn refresh_all(&self)where
Self: ISourceCache<T, K>,
Signals that every item has changed (
Refresh()).Source§fn remove(&self, item: &T)where
Self: ISourceCache<T, K>,
fn remove(&self, item: &T)where
Self: ISourceCache<T, K>,
Removes the item of the key of
item (Remove(TObject)).Source§fn remove_items(&self, items: impl IntoIterator<Item = T>)where
Self: ISourceCache<T, K>,
fn remove_items(&self, items: impl IntoIterator<Item = T>)where
Self: ISourceCache<T, K>,
Removes the items of the keys of
items (Remove(IEnumerable<TObject>)).Source§fn remove_key(&self, key: K)where
Self: ISourceCache<T, K>,
fn remove_key(&self, key: K)where
Self: ISourceCache<T, K>,
Removes the item of
key (RemoveKey(TKey), and Remove(TKey)).Source§fn remove_keys(&self, keys: impl IntoIterator<Item = K>)where
Self: ISourceCache<T, K>,
fn remove_keys(&self, keys: impl IntoIterator<Item = K>)where
Self: ISourceCache<T, K>,
Removes the items of
keys (RemoveKeys(IEnumerable<TKey>), and
Remove(IEnumerable<TKey>)).Source§fn watch_value(&self, key: K) -> Rc<dyn IObservable<T>>
fn watch_value(&self, key: K) -> Rc<dyn IObservable<T>>
The item of
key each time it changes (WatchValue(IObservableCache, TKey)).