Skip to main content

Timer

Trait Timer 

Source
pub trait Timer {
    type SleepFuture<'a>: Future<Output = ()>
       where Self: 'a;

    // Required method
    fn sleep(&self, duration: Duration) -> Self::SleepFuture<'_>;
}
Expand description

Executor-agnostic sleep primitive.

simple-someip needs timed waits in two places: the Service Discovery announcement tick (1 s) and the client event-loop idle timeout (125 ms). Consumers provide a Timer at startup; on std + tokio this is a one-line wrapper around tokio::time::sleep, on embedded it is a one-line wrapper around embassy_time::Timer::after or similar.

Required Associated Types§

Source

type SleepFuture<'a>: Future<Output = ()> where Self: 'a

Future returned by Self::sleep.

As an associated GAT, consumers can require Send at use sites (where for<'a> Tm::SleepFuture<'a>: Send) without forcing every backend’s sleep future to be Send. Multi-threaded callers (Server::announcement_loop, the tokio Client) add the bound; single-threaded callers do not, accepting a !Send future from a backend like embassy_time.

Required Methods§

Source

fn sleep(&self, duration: Duration) -> Self::SleepFuture<'_>

Wait for at least duration before resolving. Implementations MAY overshoot but MUST NOT undershoot.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§