Enum caches::PutResult

source ·
pub enum PutResult<K, V> {
    Put,
    Update(V),
    Evicted {
        key: K,
        value: V,
    },
    EvictedAndUpdate {
        evicted: (K, V),
        update: V,
    },
}
Expand description

PutResult is returned when try to put a entry in cache.

  • PutResult::Put means that the key is not in cache previously, and the cache has enough capacity, no evict happens.

  • PutResult::Update means that the key already exists in the cache, and this operation updates the key’s value and the inner is the old value.

  • PutResult::Evicted means that the the key is not in cache previously, but the cache is full, so the evict happens. The inner is the evicted entry (Key, Value).

  • PutResult::EvictedAndUpdate is only possible to be returned by TwoQueueCache and AdaptiveCache. For more information, please see the related examples of TwoQueueCache and AdaptiveCache

Variants

Put

Put means that the key is not in cache previously, and the cache has enough capacity, no evict happens.

Update(V)

Update means that the key already exists in the cache, and this operation updates the key’s value and the inner is the old value

Evicted

Fields

key: K

The key for the evicted entry.

value: V

The value for the evicted entry.

Evicted means that the the key is not in cache previously, but the cache is full, so the evict happens. The inner is the evicted entry (Key, Value).

EvictedAndUpdate

Fields

evicted: (K, V)

The evicted entry.

update: V

The old value for the updated entry.

EvictedAndUpdate is only possible to be returned by TwoQueueCache.

For more information, please see the related examples of TwoQueueCache.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.