Skip to main content

TimerSchedule

Trait TimerSchedule 

Source
pub trait TimerSchedule:
    Debug
    + Send
    + Sync {
    // Required methods
    fn start_time_ns(&self) -> UnixNanos;
    fn next_after(
        &self,
        time_ns: UnixNanos,
        index: &mut u64,
    ) -> Option<UnixNanos>;
}
Expand description

Supplies UTC deadlines for a recurring timer independently of its delivery mechanism.

Implementations are immutable and may be shared between timers. Each timer owns its own occurrence index. Live timers can skip missed occurrences, while virtual timers replay each deadline. The deadline calculation must not invoke callbacks or alter clock state.

Required Methods§

Source

fn start_time_ns(&self) -> UnixNanos

Returns the nominal start timestamp, including an explicit UNIX epoch start.

Source

fn next_after(&self, time_ns: UnixNanos, index: &mut u64) -> Option<UnixNanos>

Returns the first deadline strictly after time_ns, updating the occurrence index.

index is a hint from the preceding calculation, initially zero. A fresh hint must also work after a timer restart. Returns None when no later deadline is representable.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§