[][src]Struct async_speed_limit::clock::ManualClock

pub struct ManualClock(_);

A Clock where the passage of time can be manually controlled.

This type is mainly used for testing behavior of speed limiter only.

This clock only supports up to 264 ns (about 584.5 years).

Examples

use async_speed_limit::clock::{Clock, ManualClock, Nanoseconds};

let clock = ManualClock::new();
assert_eq!(clock.now(), Nanoseconds(0));
clock.set_time(Nanoseconds(1_000_000_000));
assert_eq!(clock.now(), Nanoseconds(1_000_000_000));

Methods

impl ManualClock[src]

pub fn new() -> Self[src]

Creates a new clock with time set to 0.

pub fn set_time(&self, time: Nanoseconds)[src]

Set the current time of this clock to the given value.

Panics

Since now() must be monotonically increasing, if the new time is less than the previous time, this function will panic.

Trait Implementations

impl Clock for ManualClock[src]

type Instant = Nanoseconds

Type to represent a point of time. Read more

type Delay = ManualDelay

Future type returned by sleep().

impl Clone for ManualClock[src]

impl Debug for ManualClock[src]

impl Default for ManualClock[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.