ArcCache

Struct ArcCache 

Source
pub struct ArcCache<K, V, S = RandomState>
where K: Eq + Hash, S: BuildHasher,
{ /* private fields */ }

Implementations§

Source§

impl<K, V> ArcCache<K, V>
where K: Eq + Hash,

Source

pub fn new(capacity: usize) -> Result<Self, &'static str>

Source§

impl<K, V, S> ArcCache<K, V, S>
where K: Eq + Hash, S: BuildHasher,

Source

pub fn with_hasher( capacity: usize, hash_builder: S, ) -> Result<Self, &'static str>
where S: Clone,

Creates an empty cache that can hold at most capacity items with the given hash builder.

Source

pub fn contains_key<Q>(&mut self, key: &Q) -> bool
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Source

pub fn insert(&mut self, key: K, value: V) -> bool

Source

pub fn peek_mut(&mut self, key: &K) -> Option<&mut V>
where K: Clone + Hash + Eq,

Source

pub fn get_mut(&mut self, key: &K) -> Option<&mut V>
where K: Clone + Hash + Eq,

Source

pub fn remove(&mut self, key: &K) -> Option<V>

Source

pub fn clear(&mut self)

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn frequent_len(&self) -> usize

Source

pub fn recent_len(&self) -> usize

Source

pub fn inserted(&self) -> u64

Source

pub fn evicted(&self) -> u64

Source

pub fn removed(&self) -> u64

Trait Implementations§

Source§

impl<'a, K, V, S> IntoIterator for &'a ArcCache<K, V, S>
where K: Eq + Hash, S: BuildHasher,

Source§

type Item = (&'a K, &'a V)

The type of the elements being iterated over.
Source§

type IntoIter = ArcCacheIterator<'a, K, V>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<K, V, S> Freeze for ArcCache<K, V, S>
where S: Freeze,

§

impl<K, V, S> RefUnwindSafe for ArcCache<K, V, S>

§

impl<K, V, S> Send for ArcCache<K, V, S>
where K: Send, V: Send, S: Send,

§

impl<K, V, S> Sync for ArcCache<K, V, S>
where K: Sync, V: Sync, S: Sync,

§

impl<K, V, S> Unpin for ArcCache<K, V, S>
where S: Unpin,

§

impl<K, V, S> UnwindSafe for ArcCache<K, V, S>

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