Trait governor::clock::Reference

source ·
pub trait Reference: Sized + Add<Nanos, Output = Self> + PartialEq + Eq + Ord + Copy + Clone + Send + Sync + Debug {
    // Required methods
    fn duration_since(&self, earlier: Self) -> Nanos;
    fn saturating_sub(&self, duration: Nanos) -> Self;
}
Expand description

A measurement from a clock.

Required Methods§

source

fn duration_since(&self, earlier: Self) -> Nanos

Determines the time that separates two measurements of a clock. Implementations of this must perform a saturating subtraction - if the earlier timestamp should be later, duration_since must return the zero duration.

source

fn saturating_sub(&self, duration: Nanos) -> Self

Returns a reference point that lies at most duration in the past from the current reference. If an underflow should occur, returns the current reference.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Reference for Duration

source§

fn duration_since(&self, earlier: Self) -> Nanos

The internal duration between this point and another.

let diff = Duration::from_secs(20).duration_since(Duration::from_secs(10));
assert_eq!(diff, Duration::from_secs(10).into());
source§

fn saturating_sub(&self, duration: Nanos) -> Self

The internal duration between this point and another.

let diff = Reference::saturating_sub(&Duration::from_secs(20), Duration::from_secs(10).into());
assert_eq!(diff, Duration::from_secs(10));
source§

impl Reference for Instant

source§

fn duration_since(&self, earlier: Self) -> Nanos

source§

fn saturating_sub(&self, duration: Nanos) -> Self

source§

impl Reference for SystemTime

source§

fn duration_since(&self, earlier: Self) -> Nanos

Returns the difference in times between the two SystemTimes. Due to the fallible nature of SystemTimes, returns the zero duration if a negative duration would result (e.g. due to system clock adjustments).

source§

fn saturating_sub(&self, duration: Nanos) -> Self

Implementors§