Struct bsec::clock::test_support::FakeClock[][src]

pub struct FakeClock { /* fields omitted */ }

A fake Clock for unit tests that can be advanced manually.

Each call to FakeClock::timestamp_ns will advance by one nanosecond.

Example

let clock = FakeClock::new();
assert_eq!(clock.timestamp_ns(), 1);
assert_eq!(clock.timestamp_ns(), 2);
assert_eq!(clock.timestamp_ns(), 3);
clock.advance_by(std::time::Duration::from_nanos(5));
assert_eq!(clock.timestamp_ns(), 9);

Implementations

impl FakeClock[src]

pub fn new() -> Self[src]

Create a new FakeClock initialized with a zero timestamp.

impl FakeClock[src]

pub fn advance_by(&self, duration: Duration)[src]

Advance the clock’s internal time by duration.

Trait Implementations

impl Clock for FakeClock[src]

fn timestamp_ns(&self) -> i64[src]

Returns the current timestamp and advances it by one.

impl Default for FakeClock[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, 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.