pub struct FakeTimer {
clock: Arc<Mutex<FakeClock>>,
deadline_ns: Option<u64>,
interval: Option<Duration>,
event: Event,
}
Expand description
FakeTimer: For use in tests.
Fields§
§clock: Arc<Mutex<FakeClock>>
§deadline_ns: Option<u64>
§interval: Option<Duration>
§event: Event
Implementations§
source§impl FakeTimer
impl FakeTimer
sourcepub fn new(clock: Arc<Mutex<FakeClock>>) -> Self
pub fn new(clock: Arc<Mutex<FakeClock>>) -> Self
Creates a new fake Timer. The timer is initally disarmed and must be armed by calling
reset
.
fn reset(&mut self, dur: Duration) -> Result<()>
sourcefn wait_for(&mut self, timeout: Option<Duration>) -> Result<WaitResult>
fn wait_for(&mut self, timeout: Option<Duration>) -> Result<WaitResult>
Waits until the timer expires or an optional wait timeout expires, whichever happens first.
§Returns
WaitResult::Expired
if the timer expired.WaitResult::Timeout
iftimeout
was notNone
and the timer did not expire within the specified timeout period.
Trait Implementations§
source§impl AsRawDescriptor for FakeTimer
impl AsRawDescriptor for FakeTimer
source§fn as_raw_descriptor(&self) -> RawDescriptor
fn as_raw_descriptor(&self) -> RawDescriptor
Returns the underlying raw descriptor. Read more
source§impl IntoRawDescriptor for FakeTimer
impl IntoRawDescriptor for FakeTimer
fn into_raw_descriptor(self) -> RawDescriptor
source§impl TimerTrait for FakeTimer
impl TimerTrait for FakeTimer
source§fn reset_oneshot(&mut self, dur: Duration) -> Result<()>
fn reset_oneshot(&mut self, dur: Duration) -> Result<()>
Sets the timer to expire after
dur
without repeating. Cancels any existing timer.source§fn reset_repeating(&mut self, dur: Duration) -> Result<()>
fn reset_repeating(&mut self, dur: Duration) -> Result<()>
Sets the timer to fire repeatedly at
dur
intervals. Cancels any existing timer.source§fn mark_waited(&mut self) -> Result<bool>
fn mark_waited(&mut self) -> Result<bool>
After a timer is triggered from an EventContext, mark the timer as having been waited for.
If a timer is not marked waited, it will immediately trigger the event context again. This
does not need to be called after calling Timer::wait. Read more
source§fn resolution(&self) -> Result<Duration>
fn resolution(&self) -> Result<Duration>
Returns the resolution of timers on the host.
Auto Trait Implementations§
impl RefUnwindSafe for FakeTimer
impl Send for FakeTimer
impl Sync for FakeTimer
impl Unpin for FakeTimer
impl UnwindSafe for FakeTimer
Blanket Implementations§
source§impl<T> AsRawDescriptors for Twhere
T: AsRawDescriptor,
impl<T> AsRawDescriptors for Twhere
T: AsRawDescriptor,
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