pub struct MockClock { /* private fields */ }Expand description
Deterministic mock clock for testing. Time advances only when explicitly set or stepped.
Implementations§
Source§impl MockClock
impl MockClock
pub fn new(initial_time: NtpTimestamp) -> Self
Sourcepub fn set_time(&self, time: NtpTimestamp)
pub fn set_time(&self, time: NtpTimestamp)
Set the current time directly.
Sourcepub fn set_adjustable(&self, adjustable: bool)
pub fn set_adjustable(&self, adjustable: bool)
Set whether this clock can be adjusted.
Sourcepub fn get_frequency(&self) -> f64
pub fn get_frequency(&self) -> f64
Get current frequency offset.
Trait Implementations§
Source§impl Clock for MockClock
impl Clock for MockClock
Source§fn now(&self) -> Result<NtpTimestamp, ClockError>
fn now(&self) -> Result<NtpTimestamp, ClockError>
Read current time from this clock.
Source§fn step(&self, offset: NtpDuration) -> Result<(), ClockError>
fn step(&self, offset: NtpDuration) -> Result<(), ClockError>
Apply a step adjustment (instant offset). Requires privilege.
Source§fn adjust_frequency(&self, ppm: f64) -> Result<(), ClockError>
fn adjust_frequency(&self, ppm: f64) -> Result<(), ClockError>
Apply a slew adjustment (frequency change in PPM). Requires privilege.
Source§fn frequency_offset(&self) -> Result<f64, ClockError>
fn frequency_offset(&self) -> Result<f64, ClockError>
Read current frequency offset in PPM.
Source§fn resolution(&self) -> NtpDuration
fn resolution(&self) -> NtpDuration
Get clock resolution as a duration.
Source§fn max_frequency_adjustment(&self) -> f64
fn max_frequency_adjustment(&self) -> f64
Maximum allowed frequency adjustment in PPM.
Source§fn is_adjustable(&self) -> bool
fn is_adjustable(&self) -> bool
Whether this clock supports discipline (has CAP_SYS_TIME or equivalent).
Auto Trait Implementations§
impl Freeze for MockClock
impl RefUnwindSafe for MockClock
impl Send for MockClock
impl Sync for MockClock
impl Unpin for MockClock
impl UnsafeUnpin for MockClock
impl UnwindSafe for MockClock
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