Struct local_clock::SystemTimeClock
source · pub struct SystemTimeClock { /* private fields */ }
Expand description
An implementation of LocalClock
backed by std::time::SystemTime
.
§A note on Time Travel
The time reported by std::time::SystemTime
may be radically altered by
external factors, such as the system operator manually setting the global
system clock. If this happens, SystemTimeClock
will also jump
forwards/backwards in time in-tandem, depending on how far the clock was
rolled back/forwards!
If this is something that concerns you, you might want to consider writing a
custom LocalClock
implementation backed by something akin to Linux’s
CLOCK_BOOTTIME
, which provides a stable monotonically increasing clock
resilient against host suspends / resumes, and not subject to unexpected
negative / positive time jumps.
Implementations§
source§impl SystemTimeClock
impl SystemTimeClock
sourcepub fn new() -> SystemTimeClock
pub fn new() -> SystemTimeClock
Create a new SystemTimeClock
, set to the current SystemTime
.
Trait Implementations§
source§impl Debug for SystemTimeClock
impl Debug for SystemTimeClock
source§impl Inspect for SystemTimeClock
impl Inspect for SystemTimeClock
source§impl LocalClock for SystemTimeClock
impl LocalClock for SystemTimeClock
source§fn get_time(&mut self) -> LocalClockTime
fn get_time(&mut self) -> LocalClockTime
Return the current clock time. Read more
source§fn set_time(&mut self, new_time: LocalClockTime)
fn set_time(&mut self, new_time: LocalClockTime)
Set the current clock time.
Auto Trait Implementations§
impl Freeze for SystemTimeClock
impl RefUnwindSafe for SystemTimeClock
impl Send for SystemTimeClock
impl Sync for SystemTimeClock
impl Unpin for SystemTimeClock
impl UnwindSafe for SystemTimeClock
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