pub struct TimerangeBound<T> { /* private fields */ }
Expand description

A TimeBound object that is valid for a specified range of time.

The range is given as an argument, as in t1..t2.

use std::time::{SystemTime, Duration};
use tor_checkable::{Timebound, TimeValidityError, timed::TimerangeBound};

let now = SystemTime::now();
let one_hour = Duration::new(3600, 0);

// This seven is only valid for another hour!
let seven = TimerangeBound::new(7_u32, ..now+one_hour);

assert_eq!(seven.check_valid_at(&now).unwrap(), 7);

// That consumed the previous seven. Try another one.
let seven = TimerangeBound::new(7_u32, ..now+one_hour);
assert_eq!(seven.check_valid_at(&(now+2*one_hour)),
           Err(TimeValidityError::Expired(one_hour)));

Implementations

Construct a new TimerangeBound object from a given object and range.

Note that we do not distinguish between inclusive and exclusive bounds: x..y and x..=y are treated the same here.

Adjust this time-range bound to tolerate an expiration time farther in the future.

Adjust this time-range bound to tolerate an initial validity time farther in the past.

Consume this TimeRangeBound, and return its underlying time bounds and object.

The caller takes responsibility for making sure that the bounds are actually checked.

This is an experimental API. Using it voids your stability guarantees. It is only available when this crate is compiled with the experimental-api feature.

Return a reference to the inner object of this TimeRangeBound, without checking the time interval.

The caller takes responsibility for making sure that nothing is actually done with the inner object that would rely on the bounds being correct, until the bounds are (eventually) checked.

This is an experimental API. Using it voids your stability guarantees. It is only available when this crate is compiled with the experimental-api feature.

Trait Implementations

An error type that’s returned when the object is not timely.

Check whether this object is valid at a given time. Read more

Return the underlying object without checking whether it’s valid.

Unwrap this Timebound object if it is valid at a given time.

Unwrap this Timebound object if it is valid now.

Unwrap this object if it is valid at the provided time t. If no time is provided, check the object at the current time. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.