pub struct FixedClock(/* private fields */);Expand description
A Clock that always returns a configured time until FixedClock::set
changes it.
§Examples
use ddd_toolkit_core::mock::clock::FixedClock;
use ddd_toolkit_core::port::clock::Clock;
let noon = "2026-07-21T12:00:00Z".parse().unwrap();
let clock = FixedClock::new(noon);
// now() returns the configured instant, regardless of wall-clock time...
assert_eq!(clock.now(), noon);
// ...until the test explicitly advances it.
let evening = "2026-07-21T18:00:00Z".parse().unwrap();
clock.set(evening);
assert_eq!(clock.now(), evening);Implementations§
Source§impl FixedClock
impl FixedClock
Sourcepub fn new(now: DateTime<Utc>) -> FixedClock
pub fn new(now: DateTime<Utc>) -> FixedClock
Creates a FixedClock that returns now until FixedClock::set
is called.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for FixedClock
impl RefUnwindSafe for FixedClock
impl Send for FixedClock
impl Sync for FixedClock
impl Unpin for FixedClock
impl UnsafeUnpin for FixedClock
impl UnwindSafe for FixedClock
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