Struct base::FakeTimer

source ·
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

source

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.

source

fn reset(&mut self, dur: Duration) -> Result<()>

source

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 if timeout was not None and the timer did not expire within the specified timeout period.

Trait Implementations§

source§

impl AsRawDescriptor for FakeTimer

source§

fn as_raw_descriptor(&self) -> RawDescriptor

Returns the underlying raw descriptor. Read more
source§

impl IntoRawDescriptor for FakeTimer

source§

impl TimerTrait for FakeTimer

source§

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<()>

Sets the timer to fire repeatedly at dur intervals. Cancels any existing timer.
source§

fn wait(&mut self) -> Result<()>

Waits until the timer expires.
source§

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 clear(&mut self) -> Result<()>

Disarms the timer.
source§

fn resolution(&self) -> Result<Duration>

Returns the resolution of timers on the host.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> AsRawDescriptors for T
where T: AsRawDescriptor,

source§

fn as_raw_descriptors(&self) -> Vec<i32>

Returns the underlying raw descriptors. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.