pub struct Time<Effect, Event> { /* private fields */ }Expand description
Time capability API.
This capability provides access to the current time and allows the app to ask for notifications when a specific instant has arrived or a duration has elapsed.
The capability also supports cancellation from the core side, using the TimerHandle
returned by notify_at and notify_after.
Implementations§
Source§impl<Effect, Event> Time<Effect, Event>
impl<Effect, Event> Time<Effect, Event>
Sourcepub fn now() -> RequestBuilder<Effect, Event, impl Future<Output = SystemTime>>
pub fn now() -> RequestBuilder<Effect, Event, impl Future<Output = SystemTime>>
Sourcepub fn notify_at(
system_time: SystemTime,
) -> (RequestBuilder<Effect, Event, impl Future<Output = TimerOutcome>>, TimerHandle)
pub fn notify_at( system_time: SystemTime, ) -> (RequestBuilder<Effect, Event, impl Future<Output = TimerOutcome>>, TimerHandle)
Ask to receive a notification when the specified
[SystemTime] has arrived. Returns the RequestBuilder alongside a TimerHandle,
which can be stored and used to clear the timer.
§Panics
Panics if the response is not TimeResponse::InstantArrived
or if the timer ID is not the same as the one used to create the handle.
Sourcepub fn notify_after(
duration: Duration,
) -> (RequestBuilder<Effect, Event, impl Future<Output = TimerOutcome>>, TimerHandle)
pub fn notify_after( duration: Duration, ) -> (RequestBuilder<Effect, Event, impl Future<Output = TimerOutcome>>, TimerHandle)
Ask to receive a notification after the specified
Duration has elapsed. Returns the RequestBuilder alongside a TimerHandle,
which can be stored and used to clear the timer.
§Panics
Panics if the response is not TimeResponse::DurationElapsed
or if the timer ID is not the same as the one used to create the handle.