# ChangeAwareCache

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-dynamic-data/cache/struct-changeawarecache/

**struct** · [`ferroui-dynamic-data`](/docs/0.5.0/api/ferroui-dynamic-data/) · v0.5.0

```rust
struct ChangeAwareCache<T, K>
```

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

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/change_aware_cache.rs#L10)

## Members

- [`new`](#function-new)
- [`with_capacity`](#function-with_capacity)
- [`from_dictionary`](#function-from_dictionary)
- [`into_dictionary`](#function-into_dictionary)
- [`add`](#function-add)
- [`capture_changes`](#function-capture_changes)
- [`has_changes`](#function-has_changes)

<a id="function-new"></a>

### new

```rust
fn new() -> Self
```

An empty cache.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/change_aware_cache.rs#L23)

<a id="function-with_capacity"></a>

### with_capacity

```rust
fn with_capacity(capacity: usize) -> Self
```

An empty cache with room for `capacity` items.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/change_aware_cache.rs#L28)

<a id="function-from_dictionary"></a>

### from_dictionary

```rust
fn from_dictionary(data: IndexMap<K, T>) -> Self
```

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

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/change_aware_cache.rs#L34)

<a id="function-into_dictionary"></a>

### into_dictionary

```rust
fn into_dictionary(self: Self) -> IndexMap<K, T>
```

The items in the order of enumeration of the cache, giving up the cache.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/change_aware_cache.rs#L50)

<a id="function-add"></a>

### add

```rust
fn add(self: &mut Self, item: T, key: K)
```

Adds an item (`Add`).
## Panics
When the key is there already (`ArgumentException` of the dictionary).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/change_aware_cache.rs#L63)

<a id="function-capture_changes"></a>

### capture_changes

```rust
fn capture_changes(self: &mut Self) -> ChangeSet<T, K>
```

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

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/change_aware_cache.rs#L69)

<a id="function-has_changes"></a>

### has_changes

```rust
fn has_changes(self: &Self) -> bool
```

Whether there are changes not captured yet.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/change_aware_cache.rs#L77)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `Default`
- [`IQuery<T, K>`](/docs/0.5.0/api/ferroui-dynamic-data/cache/trait-iquery/)
- [`ICache<T, K>`](/docs/0.5.0/api/ferroui-dynamic-data/cache/trait-icache/)

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
