pub struct FakeClock { /* private fields */ }
Expand description
A fake clock that can be used in tests to give exact control over the time. For a code example, see the tests in sys_util/src/timerfd.rs.
Implementations§
Source§impl FakeClock
impl FakeClock
pub fn new() -> Self
Sourcepub fn duration_since(&self, earlier: &Self) -> Duration
pub fn duration_since(&self, earlier: &Self) -> Duration
Get the duration since |earlier|, assuming that earlier < self.
Sourcepub fn add_event_fd(&mut self, deadline_ns: u64, fd: EventFd)
pub fn add_event_fd(&mut self, deadline_ns: u64, fd: EventFd)
Register the event fd for a notification when self’s time is |deadline_ns|. Drop any existing events registered to the same raw fd.
pub fn add_ns(&mut self, ns: u64)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FakeClock
impl RefUnwindSafe for FakeClock
impl Send for FakeClock
impl Sync for FakeClock
impl Unpin for FakeClock
impl UnwindSafe for FakeClock
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