Trait tor_checkable::Timebound [−][src]
pub trait Timebound<T>: Sized {
type Error;
fn is_valid_at(&self, t: &SystemTime) -> Result<(), Self::Error>;
fn dangerously_assume_timely(self) -> T;
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.
Associated Types
Required methods
fn 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.
fn dangerously_assume_timely(self) -> T
fn dangerously_assume_timely(self) -> T
Return the underlying object without checking whether it’s valid.
Provided methods
fn 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.
fn 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.
fn 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.