DashCache

Struct DashCache 

Source
pub struct DashCache<C, S = RandomState> { /* private fields */ }
Expand description

A global cache built around a DashMap

Implementations§

Source§

impl<C: Hash + Eq> DashCache<C>

Source

pub fn new() -> DashCache<C>

Create a new, empty DashCache

Trait Implementations§

Source§

impl<C, S> Debug for DashCache<C, S>
where C: Debug + Hash + Eq, S: BuildHasher + Clone,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<C: Hash + Eq, S: BuildHasher + Clone + Default> Default for DashCache<C, S>

Source§

fn default() -> DashCache<C, S>

Returns the “default value” for a type. Read more
Source§

impl<C, S> From<DashMap<C, (), S>> for DashCache<C, S>

Source§

fn from(cache: DashMap<C, (), S>) -> DashCache<C, S>

Converts to this type from the input type.
Source§

impl<C, S> GlobalCache for DashCache<C, S>
where S: BuildHasher + Clone, C: Hash + Eq + Clone + CanCollect,

Source§

type Entry = C

The cache entry type
Source§

fn cache<Q>(&self, value: Q) -> C
where C: Borrow<Q>, Q: Into<C> + Hash + Eq,

Attempt to cache a value. If already cached, return the corresponding entry. Read more
Source§

fn gc(&self) -> usize

Attempt to garbage-collect this cache, returning how many elements were removed. Read more
Source§

fn try_gc(&self, key: &mut Self::Entry) -> Option<Self::Entry>

Garbage collect a single entry if doing so would not break the hash-consing property due to uniqueness. Returns the removed key on success, or Err(key) on failure Read more
Source§

fn try_gc_global(&self, key: &Self::Entry) -> Option<Self::Entry>

Garbage collect a single entry if doing so would not break the hash-consing property due to uniqueness. Returns the removed key on success, or Err(key) on failure. Read more
Source§

fn len(&self) -> usize

Compute how many items are in a given cache. Read more
Source§

fn is_empty(&self) -> bool

Check if a cache is empty Read more

Auto Trait Implementations§

§

impl<C, S> Freeze for DashCache<C, S>
where S: Freeze,

§

impl<C, S = RandomState> !RefUnwindSafe for DashCache<C, S>

§

impl<C, S> Send for DashCache<C, S>
where S: Send, C: Send,

§

impl<C, S> Sync for DashCache<C, S>
where S: Sync + Send, C: Send + Sync,

§

impl<C, S> Unpin for DashCache<C, S>
where S: Unpin,

§

impl<C, S> UnwindSafe for DashCache<C, S>
where S: UnwindSafe, C: UnwindSafe,

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

Source§

const ACK_1_1_0: bool = true

Whether this implementor has acknowledged the 1.1.0 update to unerase’s documented implementation requirements. Read more
Source§

unsafe fn unerase(this: NonNull<Erased>) -> NonNull<T>

Unerase this erased pointer. Read more
Source§

fn erase(this: NonNull<Self>) -> NonNull<Erased>

Turn this erasable pointer into an erased pointer. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. 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.