Trait bsec::clock::Clock[][src]

pub trait Clock {
    fn timestamp_ns(&self) -> i64;
}

The BSEC algorithem needs a clock capable of providing timestamps. Implement this trait according to your hardware platform.

Example

A possible implementation based on std::time could look like this:

use bsec::clock::Clock;
use std::time::{Duration, Instant};

pub struct TimePassed {
    start: Instant,
}

impl TimePassed {
    fn new() -> Self {
        Self { start: Instant::now() }
    }
}

impl Clock for TimePassed {
    fn timestamp_ns(&self) -> i64 {
        self.start.elapsed().as_nanos() as i64
    }
}

Required methods

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

Return a monotonically increasing timestamp with nanosecond resolution.

The reference point may be arbitrary.

Loading content...

Implementors

impl Clock for TimePassed[src]

impl Clock for FakeClock[src]

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

Returns the current timestamp and advances it by one.

Loading content...