pub struct Clock { /* private fields */ }Expand description
The test clock.
Implementations§
Source§impl Clock
impl Clock
Sourcepub fn new(
start: OffsetDateTime,
end: OffsetDateTime,
events: Vec<Event>,
) -> Self
pub fn new( start: OffsetDateTime, end: OffsetDateTime, events: Vec<Event>, ) -> Self
A clock at start that stops at end, with events (sorted on construction).
Sourcepub const fn now(&self) -> OffsetDateTime
pub const fn now(&self) -> OffsetDateTime
The current instant.
Sourcepub const fn end(&self) -> OffsetDateTime
pub const fn end(&self) -> OffsetDateTime
Where the clock stops.
Sourcepub fn events(&self) -> &[Event]
pub fn events(&self) -> &[Event]
Every scheduled event of the replay, in time order (past and future).
Sourcepub fn advance_to(
&mut self,
to: OffsetDateTime,
) -> Result<Vec<Event>, ClockError>
pub fn advance_to( &mut self, to: OffsetDateTime, ) -> Result<Vec<Event>, ClockError>
Moves to to (capped at the end) and returns the events passed, in order.
§Errors
ClockError::Backwards if to is before now.
Sourcepub fn advance_next(&mut self) -> Vec<Event>
pub fn advance_next(&mut self) -> Vec<Event>
Moves to the next event (or the end) and returns the events fired there.
Trait Implementations§
Auto Trait Implementations§
impl Forget for Clock
impl Freeze for Clock
impl Move for Clock
impl RefUnwindSafe for Clock
impl Send for Clock
impl Sync for Clock
impl Unpin for Clock
impl UnsafeUnpin for Clockwhere
NonZeroI32Inner: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<Event>: UnsafeUnpin,
impl UnwindSafe for Clock
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