pub struct CacheEntry { /* private fields */ }Expand description
A type-erased cache entry for storing provider results with timestamp and reference counting
Implementations§
Source§impl CacheEntry
impl CacheEntry
pub fn new<T: Clone + Send + Sync + 'static>(data: T) -> Self
pub fn get<T: Clone + Send + Sync + 'static>(&self) -> Option<T>
pub fn is_expired(&self, expiration: Duration) -> bool
pub fn is_stale(&self, stale_time: Duration) -> bool
Sourcepub fn add_reference(&self)
pub fn add_reference(&self)
Increment reference count when a provider hook starts using this entry
Sourcepub fn remove_reference(&self)
pub fn remove_reference(&self)
Decrement reference count when a provider hook stops using this entry
Sourcepub fn reference_count(&self) -> u32
pub fn reference_count(&self) -> u32
Get current reference count
Sourcepub fn access_count(&self) -> u32
pub fn access_count(&self) -> u32
Get current access count
Sourcepub fn is_unused_for(&self, duration: Duration) -> bool
pub fn is_unused_for(&self, duration: Duration) -> bool
Check if this entry hasn’t been accessed for the given duration
Sourcepub fn time_since_last_access(&self) -> Duration
pub fn time_since_last_access(&self) -> Duration
Get the time since this entry was last accessed
Trait Implementations§
Source§impl Clone for CacheEntry
impl Clone for CacheEntry
Source§fn clone(&self) -> CacheEntry
fn clone(&self) -> CacheEntry
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for CacheEntry
impl !RefUnwindSafe for CacheEntry
impl Send for CacheEntry
impl Sync for CacheEntry
impl Unpin for CacheEntry
impl !UnwindSafe for CacheEntry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> InitializeFromFunction<T> for T
impl<T> InitializeFromFunction<T> for T
Source§fn initialize_from_function(f: fn() -> T) -> T
fn initialize_from_function(f: fn() -> T) -> T
Create an instance of this type from an initialization function
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<Ret> SpawnIfAsync<(), Ret> for Ret
impl<Ret> SpawnIfAsync<(), Ret> for Ret
Source§impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
Source§fn super_from(input: T) -> O
fn super_from(input: T) -> O
Convert from a type to another type.
Source§impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
Source§fn super_into(self) -> O
fn super_into(self) -> O
Convert from a type to another type.