pub struct TimerOps;Expand description
TimerOps
Implementations§
Source§impl TimerOps
impl TimerOps
Sourcepub fn set(
delay: Duration,
label: impl Into<String>,
task: impl Future<Output = ()> + 'static,
) -> TimerId
pub fn set( delay: Duration, label: impl Into<String>, task: impl Future<Output = ()> + 'static, ) -> TimerId
Schedules a one-shot timer. The task is a single Future, consumed exactly once.
Sourcepub fn set_interval<F, Fut>(
interval: Duration,
label: impl Into<String>,
task: F,
) -> TimerId
pub fn set_interval<F, Fut>( interval: Duration, label: impl Into<String>, task: F, ) -> TimerId
Schedules a repeating timer. The task is a closure that produces a fresh Future on each tick.
Sourcepub fn set_guarded(
slot: &'static LocalKey<RefCell<Option<TimerId>>>,
delay: Duration,
label: impl Into<String>,
task: impl Future<Output = ()> + 'static,
) -> bool
pub fn set_guarded( slot: &'static LocalKey<RefCell<Option<TimerId>>>, delay: Duration, label: impl Into<String>, task: impl Future<Output = ()> + 'static, ) -> bool
Schedule a one-shot timer only if the slot is empty. Returns true when a new timer was scheduled.
Sourcepub fn set_guarded_interval<FInit, InitFut, FTick, TickFut>(
slot: &'static LocalKey<RefCell<Option<TimerId>>>,
init_delay: Duration,
init_label: impl Into<String>,
init_task: FInit,
interval: Duration,
interval_label: impl Into<String>,
tick_task: FTick,
) -> bool
pub fn set_guarded_interval<FInit, InitFut, FTick, TickFut>( slot: &'static LocalKey<RefCell<Option<TimerId>>>, init_delay: Duration, init_label: impl Into<String>, init_task: FInit, interval: Duration, interval_label: impl Into<String>, tick_task: FTick, ) -> bool
Schedule a guarded init timer that installs a repeating interval timer. Returns true when a new timer was scheduled. The interval is only installed if the slot still holds the init timer.
Auto Trait Implementations§
impl Freeze for TimerOps
impl RefUnwindSafe for TimerOps
impl Send for TimerOps
impl Sync for TimerOps
impl Unpin for TimerOps
impl UnwindSafe for TimerOps
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