pub struct Value<V, TS> { /* private fields */ }Expand description
Wraps a map value with a specified
expiry TimeSource.
Implementations§
Source§impl<V, TS> Value<V, TS>where
V: Clone,
TS: TimeSource,
impl<V, TS> Value<V, TS>where
V: Clone,
TS: TimeSource,
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Returns true when the specified expiry is
after the current time.
Sourcepub fn is_expired_at(&self, at: &TS) -> bool
pub fn is_expired_at(&self, at: &TS) -> bool
Returns true when the specified expiry is
after the given time at.
Sourcepub fn expires(&self) -> &TS
pub fn expires(&self) -> &TS
Returns a reference to the values expiry
TimeSource.
Sourcepub fn set_expiry(&mut self, lifetime: Duration)
pub fn set_expiry(&mut self, lifetime: Duration)
Sets the expiry of the value to now plus the given lifetime.
Sourcepub fn add_expiry(&mut self, lifetime: Duration)
pub fn add_expiry(&mut self, lifetime: Duration)
Adds the given duration to the values expiry.
Sourcepub fn value_checked(&self) -> Option<V>
pub fn value_checked(&self) -> Option<V>
Returns a copy of the inner value if the expiry has not yet exceeded.
Sourcepub fn value_ref_checked(&self) -> Option<&V>
pub fn value_ref_checked(&self) -> Option<&V>
Returns a reference to the inner value if the expiry has not yet exceeded.
Trait Implementations§
Auto Trait Implementations§
impl<V, TS> Freeze for Value<V, TS>
impl<V, TS> RefUnwindSafe for Value<V, TS>where
V: RefUnwindSafe,
TS: RefUnwindSafe,
impl<V, TS> Send for Value<V, TS>
impl<V, TS> Sync for Value<V, TS>
impl<V, TS> Unpin for Value<V, TS>
impl<V, TS> UnwindSafe for Value<V, TS>where
V: UnwindSafe,
TS: UnwindSafe,
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