Struct hirofa_utils::cache::Cache

source ·
pub struct Cache<K: Eq + Hash, O> { /* private fields */ }

Implementations§

source§

impl<K: Eq + Hash, O> Cache<K, O>

source

pub fn new<P>(producer: P, max_inactive_time: Duration, max_size: usize) -> Self
where P: Fn(&K) -> Option<O> + Send + 'static,

source

pub fn len(&self) -> usize

source

pub fn is_empty(&self) -> bool

Trait Implementations§

source§

impl<K: Eq + Hash + Clone, O> CacheIFace<K, O> for Cache<K, O>

source§

fn invalidate_all(&mut self)

source§

fn invalidate_stale(&mut self)

source§

fn opt(&mut self, key: &K) -> Option<&O>

source§

fn opt_mut(&mut self, key: &K) -> Option<&mut O>

source§

fn opt_no_touch(&self, key: &K) -> Option<&O>

source§

fn get(&mut self, key: &K) -> Option<&O>

source§

fn get_mut(&mut self, key: &K) -> Option<&mut O>

source§

fn contains_key(&self, key: &K) -> bool

source§

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

source§

fn insert(&mut self, key: K, item: O)

Auto Trait Implementations§

§

impl<K, O> !RefUnwindSafe for Cache<K, O>

§

impl<K, O> Send for Cache<K, O>
where K: Send, O: Send,

§

impl<K, O> !Sync for Cache<K, O>

§

impl<K, O> Unpin for Cache<K, O>

§

impl<K, O> !UnwindSafe for Cache<K, O>

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

§

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

§

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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V