Skip to main content

ChangeAwareCache

Struct ChangeAwareCache 

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

A keyed collection that records its changes until they are captured (ChangeAwareCache<TObject, TKey>): the building block of the cache operators.

Implementations§

Source§

impl<T: Clone, K: Eq + Hash + Clone> ChangeAwareCache<T, K>

Source

pub fn new() -> Self

An empty cache.

Source

pub fn with_capacity(capacity: usize) -> Self

An empty cache with room for capacity items.

Source

pub fn from_dictionary(data: Dictionary<K, T>) -> Self

A cache of the items of data, without changes (ChangeAwareCache(Dictionary<TKey, TObject>)).

Source

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

The underlying dictionary (GetDictionary).

Source

pub fn into_dictionary(self) -> Dictionary<K, T>

The items, giving up the cache.

Source

pub fn add(&mut self, item: T, key: K)

Adds an item (Add).

§Panics

When the key is there already (ArgumentException of the dictionary).

Source

pub fn capture_changes(&mut self) -> ChangeSet<T, K>

The changes since the last capture, and a clean slate (CaptureChanges).

Source

pub fn has_changes(&self) -> bool

Whether there are changes not captured yet.

Trait Implementations§

Source§

impl<T: Clone, K: Eq + Hash + Clone> Default for ChangeAwareCache<T, K>

Source§

fn default() -> Self

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

impl<T: Clone, K: Eq + Hash + Clone> ICache<T, K> for ChangeAwareCache<T, K>

Source§

fn add_or_update(&mut self, item: T, key: K)

Adds the item, or replaces the item of its key (AddOrUpdate(TObject, TKey)).
Source§

fn clear(&mut self)

Removes every item (Clear).
Source§

fn clone_changes(&mut self, changes: &ChangeSet<T, K>)

Applies a change set (Clone(IChangeSet<TObject, TKey>)).
Source§

fn refresh_all(&mut self)

Refreshes every item (Refresh()).
Source§

fn refresh_keys(&mut self, keys: &mut dyn Iterator<Item = K>)

Refreshes the items of the keys (Refresh(IEnumerable<TKey>)).
Source§

fn refresh(&mut self, key: &K)

Refreshes the item of key (Refresh(TKey)).
Source§

fn remove(&mut self, key: &K)

Removes the item of key (Remove(TKey)).
Source§

fn remove_keys(&mut self, keys: &mut dyn Iterator<Item = K>)

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

impl<T: Clone, K: Eq + Hash + Clone> IQuery<T, K> for ChangeAwareCache<T, K>

Source§

fn count(&self) -> usize

The number of items (Count).
Source§

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

The items, in the order of enumeration (Items).
Source§

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

The keys, in the order of enumeration (Keys).
Source§

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

The keys and items, in the order of enumeration (KeyValues).
Source§

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

The item of key (Lookup).

Auto Trait Implementations§

§

impl<T, K> Freeze for ChangeAwareCache<T, K>
where Dictionary<K, T>: Freeze, Vec<Change<T, K>>: Freeze,

§

impl<T, K> RefUnwindSafe for ChangeAwareCache<T, K>

§

impl<T, K> Send for ChangeAwareCache<T, K>
where Dictionary<K, T>: Send, Vec<Change<T, K>>: Send,

§

impl<T, K> Sync for ChangeAwareCache<T, K>
where Dictionary<K, T>: Sync, Vec<Change<T, K>>: Sync,

§

impl<T, K> Unpin for ChangeAwareCache<T, K>
where Dictionary<K, T>: Unpin, Vec<Change<T, K>>: Unpin,

§

impl<T, K> UnsafeUnpin for ChangeAwareCache<T, K>

§

impl<T, K> UnwindSafe for ChangeAwareCache<T, K>
where Dictionary<K, T>: UnwindSafe, Vec<Change<T, K>>: UnwindSafe,

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

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.