moka

Struct Entry

source
pub struct Entry<K, V> { /* private fields */ }
Expand description

A snapshot of a single entry in the cache.

Entry is constructed from the methods like or_insert on the struct returned by cache’s entry or entry_by_ref methods. Entry holds the cached key and value at the time it was constructed. It also carries extra information about the entry; is_fresh method returns true if the value was not cached and was freshly computed.

See the followings for more information about entry and entry_by_ref methods:

Implementations§

source§

impl<K, V> Entry<K, V>

source

pub fn key(&self) -> &K

Returns a reference to the wrapped key.

source

pub fn value(&self) -> &V

Returns a reference to the wrapped value.

Note that the returned reference is not pointing to the original value in the cache. Instead, it is pointing to the cloned value in this Entry.

source

pub fn into_value(self) -> V

Consumes this Entry, returning the wrapped value.

Note that the returned value is a clone of the original value in the cache. It was cloned when this Entry was constructed.

source

pub fn is_fresh(&self) -> bool

Returns true if the value in this Entry was not cached and was freshly computed.

source

pub fn is_old_value_replaced(&self) -> bool

Returns true if an old value existed in the cache and was replaced by the value in this Entry.

Note that the new value can be the same as the old value. This method still returns true in that case.

Trait Implementations§

source§

impl<K, V> Debug for Entry<K, V>
where K: Debug, V: Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<K, V> Freeze for Entry<K, V>
where V: Freeze,

§

impl<K, V> RefUnwindSafe for Entry<K, V>

§

impl<K, V> Send for Entry<K, V>
where V: Send, K: Sync + Send,

§

impl<K, V> Sync for Entry<K, V>
where V: Sync, K: Sync + Send,

§

impl<K, V> Unpin for Entry<K, V>
where V: Unpin,

§

impl<K, V> UnwindSafe for Entry<K, V>

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> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
source§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

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

source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.