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 moreSource§impl Debug for RobotClock
impl Debug for RobotClock
Auto Trait Implementations§
impl Freeze for RobotClock
impl RefUnwindSafe for RobotClock
impl Send for RobotClock
impl Sync for RobotClock
impl Unpin for RobotClock
impl UnsafeUnpin for RobotClock
impl UnwindSafe for RobotClock
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.