pub struct CachedData {
pub data: DataSource,
pub cached_at: Instant,
pub ttl: Duration,
}Expand description
Cached data entry with TTL
Fields§
§data: DataSourceThe cached data source
cached_at: InstantWhen this entry was cached
ttl: DurationTime-to-live for this entry
Implementations§
Source§impl CachedData
impl CachedData
Sourcepub fn new(data: DataSource, ttl: Duration) -> Self
pub fn new(data: DataSource, ttl: Duration) -> Self
Create a new cached entry
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if this entry has expired
Sourcepub fn remaining_ttl(&self) -> Duration
pub fn remaining_ttl(&self) -> Duration
Get remaining TTL
Trait Implementations§
Source§impl Clone for CachedData
impl Clone for CachedData
Source§fn clone(&self) -> CachedData
fn clone(&self) -> CachedData
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for CachedData
impl RefUnwindSafe for CachedData
impl Send for CachedData
impl Sync for CachedData
impl Unpin for CachedData
impl UnsafeUnpin for CachedData
impl UnwindSafe for CachedData
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