Skip to main content

SourceCache

Struct SourceCache 

Source
pub struct SourceCache<T, K> { /* private fields */ }
Expand description

The source of a reactive keyed collection (SourceCache<TObject, TKey>): edits make change sets, which connect delivers to the operators.

Implementations§

Source§

impl<T: Clone + 'static, K: Eq + Hash + Clone + 'static> SourceCache<T, K>

Source

pub fn new(key_selector: impl Fn(&T) -> K + 'static) -> Self

An empty cache whose items are keyed by key_selector.

Source

pub fn edit(&self, update: impl FnOnce(&mut dyn ISourceUpdater<T, K>))

Runs an edit (Edit(Action<ISourceUpdater>)).

Source

pub fn suspend_count(&self) -> Rc<dyn IDisposable>

Holds back the notifications of count changes (SuspendCount).

Source

pub fn suspend_notifications(&self) -> Rc<dyn IDisposable>

Holds back the notifications of changes (SuspendNotifications).

Source

pub fn as_observable_cache_inner(&self) -> &ObservableCache<T, K>

The observable cache this source edits.

Trait Implementations§

Source§

impl<T: Clone + 'static, K: Eq + Hash + Clone + 'static> CacheChangeSetSource for SourceCache<T, K>

Source§

type Item = T

The type of the items.
Source§

type Key = K

The type of the keys.
Source§

fn source_change_sets(&self) -> Rc<dyn IObservable<ChangeSet<T, K>>>

The change sets of the source: the sequence itself, or Connect() of a cache.
Source§

impl<T, K> Clone for SourceCache<T, K>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Clone + 'static, K: Eq + Hash + Clone + 'static> IConnectableCache<T, K> for SourceCache<T, K>

Source§

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

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

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

The changes of the item of key (Watch).
Source§

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,

The items that predicate accepts and their changes (Connect(Func<TObject, bool>)).
Source§

fn preview(&self) -> Rc<dyn IObservable<ChangeSet<T, K>>>

The changes before they are applied (Preview()).
Source§

impl<T: Clone + 'static, K: Eq + Hash + Clone + 'static> IDisposable for SourceCache<T, K>

Source§

fn dispose(&self)

Source§

impl<T: Clone + 'static, K: Eq + Hash + Clone + 'static> IObservableCache<T, K> for SourceCache<T, K>

Source§

fn count(&self) -> usize

The number of items (Count).
Source§

fn items(&self) -> Vec<T>

The items (Items).
Source§

fn keys(&self) -> Vec<K>

The keys (Keys).
Source§

fn key_values(&self) -> Dictionary<K, T>

The keys and items (KeyValues).
Source§

fn lookup(&self, key: &K) -> Option<T>

The item of key (Lookup).
Source§

impl<T: Clone + 'static, K: Eq + Hash + Clone + 'static> ISourceCache<T, K> for SourceCache<T, K>

Source§

fn key_selector(&self) -> KeySelector<T, K>

The key selector of the items (KeySelector).
Source§

fn edit(&self, update: &mut dyn FnMut(&mut dyn ISourceUpdater<T, K>))

Runs an edit; its changes are delivered as one change set when it ends (Edit).

Auto Trait Implementations§

§

impl<T, K> !RefUnwindSafe for SourceCache<T, K>

§

impl<T, K> !Send for SourceCache<T, K>

§

impl<T, K> !Sync for SourceCache<T, K>

§

impl<T, K> !UnwindSafe for SourceCache<T, K>

§

impl<T, K> Freeze for SourceCache<T, K>
where ObservableCache<T, K>: Freeze, Rc<dyn Fn(&T) -> K>: Freeze,

§

impl<T, K> Unpin for SourceCache<T, K>
where ObservableCache<T, K>: Unpin, Rc<dyn Fn(&T) -> K>: Unpin,

§

impl<T, K> UnsafeUnpin for SourceCache<T, K>
where ObservableCache<T, K>: UnsafeUnpin, Rc<dyn Fn(&T) -> K>: UnsafeUnpin,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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, K, C> SourceCacheEx<T, K> for C
where T: Clone + 'static, K: Eq + Hash + Clone + 'static, C: IObservableCache<T, K> + ?Sized,

Source§

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

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

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

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

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

Removes every item (Clear(ISourceCache)).
Source§

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

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)>>>
where Self: 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)).
Source§

fn expire_after_on( &self, time_selector: impl Fn(&T) -> Option<Duration> + 'static, scheduler: Rc<dyn IScheduler>, ) -> Rc<dyn IObservable<Vec<(K, T)>>>
where Self: ISourceCache<T, K> + Clone + Sized + 'static,

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)>>>
where Self: ISourceCache<T, K> + Clone + Sized + 'static,

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)>>>
where Self: ISourceCache<T, K> + Clone + Sized + 'static,

Source§

fn limit_size_to(&self, size_limit: usize) -> Rc<dyn IObservable<Vec<(K, T)>>>
where Self: 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)). Read more
Source§

fn limit_size_to_on( &self, size_limit: usize, scheduler: Rc<dyn IScheduler>, ) -> Rc<dyn IObservable<Vec<(K, T)>>>
where Self: ISourceCache<T, K> + Clone + Sized + 'static,

limit_size_to on scheduler (LimitSizeTo(ISourceCache, int, IScheduler)).
Source§

fn populate_from( &self, observable: Rc<dyn IObservable<T>>, ) -> Rc<dyn IDisposable>
where Self: ISourceCache<T, K> + Clone + Sized + 'static,

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>
where Self: ISourceCache<T, K> + Clone + Sized + 'static,

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

Signals that item has changed (Refresh(TObject)).
Source§

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

Signals that every item has changed (Refresh()).
Source§

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

Removes the items of the keys of items (Remove(IEnumerable<TObject>)).
Source§

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

Removes the items of keys (RemoveKeys(IEnumerable<TKey>), and Remove(IEnumerable<TKey>)).
Source§

fn watch_value(&self, key: K) -> Rc<dyn IObservable<T>>

The item of key each time it changes (WatchValue(IObservableCache, TKey)).
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.