pub struct TimerRegistry { /* private fields */ }Expand description
A registry for tracking timers by identifier.
Implementations§
Source§impl TimerRegistry
impl TimerRegistry
Sourcepub async fn insert(&self, timer: Timer) -> u64
pub async fn insert(&self, timer: Timer) -> u64
Inserts an existing timer and returns its identifier.
Sourcepub async fn start_once<F>(
&self,
delay: Duration,
callback: F,
) -> Result<(u64, Timer), TimerError>where
F: TimerCallback + 'static,
pub async fn start_once<F>(
&self,
delay: Duration,
callback: F,
) -> Result<(u64, Timer), TimerError>where
F: TimerCallback + 'static,
Starts and registers a one-time timer.
Sourcepub async fn start_at<F>(
&self,
deadline: Instant,
callback: F,
) -> Result<(u64, Timer), TimerError>where
F: TimerCallback + 'static,
pub async fn start_at<F>(
&self,
deadline: Instant,
callback: F,
) -> Result<(u64, Timer), TimerError>where
F: TimerCallback + 'static,
Starts and registers a one-time timer at a deadline.
Sourcepub async fn start_recurring<F>(
&self,
schedule: RecurringSchedule,
callback: F,
) -> Result<(u64, Timer), TimerError>where
F: TimerCallback + 'static,
pub async fn start_recurring<F>(
&self,
schedule: RecurringSchedule,
callback: F,
) -> Result<(u64, Timer), TimerError>where
F: TimerCallback + 'static,
Starts and registers a recurring timer.
Sourcepub async fn remove(&self, id: u64) -> Option<Timer>
pub async fn remove(&self, id: u64) -> Option<Timer>
Removes a timer from the registry and returns it.
Sourcepub async fn contains(&self, id: u64) -> bool
pub async fn contains(&self, id: u64) -> bool
Returns true when the registry tracks the given timer identifier.
Sourcepub async fn stop(&self, id: u64) -> Result<Option<TimerOutcome>, TimerError>
pub async fn stop(&self, id: u64) -> Result<Option<TimerOutcome>, TimerError>
Stops a timer by identifier when it exists.
Sourcepub async fn cancel(&self, id: u64) -> Result<Option<TimerOutcome>, TimerError>
pub async fn cancel(&self, id: u64) -> Result<Option<TimerOutcome>, TimerError>
Cancels a timer by identifier when it exists.
Sourcepub async fn pause(&self, id: u64) -> Result<bool, TimerError>
pub async fn pause(&self, id: u64) -> Result<bool, TimerError>
Pauses a timer by identifier when it exists.
Sourcepub async fn resume(&self, id: u64) -> Result<bool, TimerError>
pub async fn resume(&self, id: u64) -> Result<bool, TimerError>
Resumes a timer by identifier when it exists.
Sourcepub async fn join_all(&self) -> Vec<(u64, TimerOutcome)>
pub async fn join_all(&self) -> Vec<(u64, TimerOutcome)>
Waits for all tracked timers that have a joinable outcome.
Sourcepub async fn cancel_all(&self)
pub async fn cancel_all(&self)
Cancels all timers currently tracked by the registry.
Sourcepub async fn resume_all(&self)
pub async fn resume_all(&self)
Resumes all paused timers currently tracked by the registry.
Sourcepub async fn active_ids(&self) -> Vec<u64>
pub async fn active_ids(&self) -> Vec<u64>
Lists all active timers.
Sourcepub async fn snapshot(&self, id: u64) -> Option<RegisteredTimer>
pub async fn snapshot(&self, id: u64) -> Option<RegisteredTimer>
Returns a snapshot of a tracked timer by identifier.
Sourcepub async fn list(&self) -> Vec<RegisteredTimer>
pub async fn list(&self) -> Vec<RegisteredTimer>
Lists snapshots for all tracked timers.
Sourcepub async fn find_by_label(&self, label: &str) -> Vec<u64>
pub async fn find_by_label(&self, label: &str) -> Vec<u64>
Returns the identifiers for timers carrying a matching label.
Trait Implementations§
Source§impl Clone for TimerRegistry
impl Clone for TimerRegistry
Source§fn clone(&self) -> TimerRegistry
fn clone(&self) -> TimerRegistry
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more