pub struct ManualClock<P = Timestamp> { /* private fields */ }Expand description
A clock set and moved by hand, read on one thread.
Reading it costs a load; AtomicManualClock is the one to share across threads. It is not
Clone, since a copy would fork time: share it by reference.
§Examples
use t2t_clock::{Clock, ManualClock};
use t2t_core::{Timedelta, Timestamp};
let clock = ManualClock::new(Timestamp::UNIX_EPOCH);
clock.advance(Timedelta::SECOND);
assert_eq!(clock.now(), Timestamp::from_secs(1), "moved on by a second");
clock.set(Timestamp::from_secs(60));
assert_eq!(clock.now(), Timestamp::from_secs(60), "moved to a minute");Implementations§
Source§impl<P: TimePoint> ManualClock<P>
impl<P: TimePoint> ManualClock<P>
Trait Implementations§
Source§impl<P: TimePoint> Clock for ManualClock<P>
impl<P: TimePoint> Clock for ManualClock<P>
Source§impl<P> Debug for ManualClock<P>
impl<P> Debug for ManualClock<P>
Auto Trait Implementations§
impl<P = Timestamp> !Freeze for ManualClock<P>
impl<P = Timestamp> !RefUnwindSafe for ManualClock<P>
impl<P = Timestamp> !Sync for ManualClock<P>
impl<P> Send for ManualClock<P>
impl<P> Unpin for ManualClock<P>
impl<P> UnsafeUnpin for ManualClock<P>where
Cell<P>: UnsafeUnpin,
impl<P> UnwindSafe for ManualClock<P>where
Cell<P>: UnwindSafe,
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
Mutably borrows from an owned value. Read more