pub struct RobotClock { /* private fields */ }Expand description
A running Robot clock. The clock is a monotonic clock that starts at an arbitrary reference time. It is clone resilient, ie a clone will be the same clock, even when mocked.
Implementations§
Source§impl RobotClock
impl RobotClock
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a RobotClock using now as its reference time. It will start at 0ns incrementing monotonically. This uses the std System Time as a reference clock.
Sourcepub fn new_with_rtc(
read_rtc_ns: impl Fn() -> u64 + Send + Sync + 'static,
sleep_ns: impl Fn(u64) + Send + Sync + 'static,
) -> Self
pub fn new_with_rtc( read_rtc_ns: impl Fn() -> u64 + Send + Sync + 'static, sleep_ns: impl Fn(u64) + Send + Sync + 'static, ) -> Self
Builds a RobotClock using a reference RTC clock to calibrate with. This is mandatory to use with the no-std platforms as we have no idea where to find a reference clock.
Sourcepub fn from_ref_time(ref_time_ns: u64) -> Self
pub fn from_ref_time(ref_time_ns: u64) -> Self
Builds a monotonic clock starting at the given reference time.
Sourcepub fn from_ref_time_with_rtc(
read_rtc_ns: fn() -> u64,
sleep_ns: fn(u64),
ref_time_ns: u64,
) -> Self
pub fn from_ref_time_with_rtc( read_rtc_ns: fn() -> u64, sleep_ns: fn(u64), ref_time_ns: u64, ) -> Self
Overrides the RTC with a custom implementation, should be the same as the new_with_rtc.
Sourcepub fn mock() -> (Self, RobotClockMock)
pub fn mock() -> (Self, RobotClockMock)
Build a fake clock with a reference time of 0. The RobotMock interface enables you to control all the clones of the clock given.
Trait Implementations§
Source§impl Clone for RobotClock
impl Clone for RobotClock
Source§fn clone(&self) -> RobotClock
fn clone(&self) -> RobotClock
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more