Trait tor_checkable::Timebound
source · pub trait Timebound<T>: Sized {
type Error;
// Required methods
fn is_valid_at(&self, t: &SystemTime) -> Result<(), Self::Error>;
fn dangerously_assume_timely(self) -> T;
// Provided methods
fn check_valid_at(self, t: &SystemTime) -> Result<T, Self::Error> { ... }
fn check_valid_now(self) -> Result<T, Self::Error> { ... }
fn check_valid_at_opt(self, t: Option<SystemTime>) -> Result<T, Self::Error> { ... }
}
Expand description
A Timebound object is one that is only valid for a given range of time.
It’s better to wrap things in a TimeBound than to give them an is_valid() valid method, so that you can make sure that nobody uses the object before checking it.
Required Associated Types§
Required Methods§
sourcefn is_valid_at(&self, t: &SystemTime) -> Result<(), Self::Error>
fn is_valid_at(&self, t: &SystemTime) -> Result<(), Self::Error>
Check whether this object is valid at a given time.
Return Ok if the object is valid, and an error if the object is not.
sourcefn dangerously_assume_timely(self) -> T
fn dangerously_assume_timely(self) -> T
Return the underlying object without checking whether it’s valid.
Provided Methods§
sourcefn check_valid_at(self, t: &SystemTime) -> Result<T, Self::Error>
fn check_valid_at(self, t: &SystemTime) -> Result<T, Self::Error>
Unwrap this Timebound object if it is valid at a given time.
sourcefn check_valid_now(self) -> Result<T, Self::Error>
fn check_valid_now(self) -> Result<T, Self::Error>
Unwrap this Timebound object if it is valid now.
sourcefn check_valid_at_opt(self, t: Option<SystemTime>) -> Result<T, Self::Error>
fn check_valid_at_opt(self, t: Option<SystemTime>) -> Result<T, Self::Error>
Unwrap this object if it is valid at the provided time t. If no time is provided, check the object at the current time.
Object Safety§
This trait is not object safe.