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

pub struct ManualClock(_);
Expand description

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));

Implementations

Creates a new clock with time set to 0.

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

Type to represent a point of time. Read more

Future type returned by sleep().

Returns the current time instant. It should be monotonically increasing, but not necessarily high-precision or steady. Read more

Asynchronously sleeps the current task for the given duration. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. 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

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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.