pub struct TimerBuilder { /* private fields */ }Expand description
Builds and starts a timer with less boilerplate.
Implementations§
Source§impl TimerBuilder
impl TimerBuilder
Sourcepub fn recurring(schedule: RecurringSchedule) -> Self
pub fn recurring(schedule: RecurringSchedule) -> Self
Creates a builder for a recurring schedule.
Sourcepub fn callback_timeout(self, callback_timeout: Duration) -> Self
pub fn callback_timeout(self, callback_timeout: Duration) -> Self
Sets a timeout for each callback execution.
Sourcepub fn retry_policy(self, retry_policy: RetryPolicy) -> Self
pub fn retry_policy(self, retry_policy: RetryPolicy) -> Self
Retries failed callback executions according to the provided policy.
Sourcepub fn max_retries(self, max_retries: usize) -> Self
pub fn max_retries(self, max_retries: usize) -> Self
Retries failed callback executions up to max_retries times.
Sourcepub fn fixed_backoff(self, delay: Duration) -> Self
pub fn fixed_backoff(self, delay: Duration) -> Self
Applies a fixed delay between retry attempts.
Sourcepub fn linear_backoff(self, step: Duration) -> Self
pub fn linear_backoff(self, step: Duration) -> Self
Applies a linearly increasing delay between retry attempts.
Sourcepub fn exponential_backoff(self, base: Duration) -> Self
pub fn exponential_backoff(self, base: Duration) -> Self
Applies an exponentially increasing delay between retry attempts.
Sourcepub fn paused_start(self) -> Self
pub fn paused_start(self) -> Self
Starts the timer in the paused state.
Sourcepub fn with_events_disabled(self) -> Self
pub fn with_events_disabled(self) -> Self
Disables broadcast event emission for the timer.
Sourcepub fn tag(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn tag(self, key: impl Into<String>, value: impl Into<String>) -> Self
Adds a metadata tag for the started timer.
Sourcepub async fn start<F>(self, callback: F) -> Result<Timer, TimerError>where
F: TimerCallback + 'static,
pub async fn start<F>(self, callback: F) -> Result<Timer, TimerError>where
F: TimerCallback + 'static,
Starts the configured timer and returns the handle.
Auto Trait Implementations§
impl Freeze for TimerBuilder
impl RefUnwindSafe for TimerBuilder
impl Send for TimerBuilder
impl Sync for TimerBuilder
impl Unpin for TimerBuilder
impl UnsafeUnpin for TimerBuilder
impl UnwindSafe for TimerBuilder
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