Trait tcp::util::time::Instant

source ·
pub trait Instant:
    'static
    + Sized
    + Copy
    + Clone
    + Debug
    + Add<Self::Duration, Output = Self>
    + AddAssign<Self::Duration>
    + Sub<Self::Duration, Output = Self>
    + Sub<Self, Output = Self::Duration>
    + SubAssign<Self::Duration>
    + PartialOrd
    + Ord
    + PartialEq
    + Eq
    + Hash {
    type Duration: Duration;

    // Required methods
    fn duration_since(&self, earlier: Self) -> Self::Duration;
    fn saturating_duration_since(&self, earlier: Self) -> Self::Duration;
    fn checked_duration_since(&self, earlier: Self) -> Option<Self::Duration>;
    fn checked_add(&self, duration: Self::Duration) -> Option<Self>;
    fn checked_sub(&self, duration: Self::Duration) -> Option<Self>;
}
Expand description

A trait for time instants that follow the API of std::time::Instant. This is useful for code that should work with not just the real time, but also simulated time.

Required Associated Types§

Required Methods§

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Instant for Instant

Calls into std::time::Instant methods of the same name.

source§

type Duration = Duration

source§

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

source§

fn saturating_duration_since(&self, earlier: Self) -> Self::Duration

source§

fn checked_duration_since(&self, earlier: Self) -> Option<Self::Duration>

source§

fn checked_add(&self, duration: Self::Duration) -> Option<Self>

source§

fn checked_sub(&self, duration: Self::Duration) -> Option<Self>

Implementors§