pub struct Time<Ev> { /* private fields */ }
Expand description
The 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.
Implementations§
Source§impl<Ev> Time<Ev>where
Ev: 'static,
impl<Ev> Time<Ev>where
Ev: 'static,
pub fn new(context: CapabilityContext<TimeRequest, Ev>) -> Self
Sourcepub fn now<F>(&self, callback: F)
pub fn now<F>(&self, callback: F)
Request current time, which will be passed to the app as a TimeResponse
containing an Instant
wrapped in the event produced by the callback
.
Sourcepub async fn now_async(&self) -> TimeResponse
pub async fn now_async(&self) -> TimeResponse
Request current time, which will be passed to the app as a TimeResponse
containing an Instant
This is an async call to use with [crux_core::compose::Compose
].
Sourcepub fn notify_at<F>(&self, instant: Instant, callback: F) -> TimerId
pub fn notify_at<F>(&self, instant: Instant, callback: F) -> TimerId
Ask to receive a notification when the specified Instant
has arrived.
Sourcepub fn notify_at_async(
&self,
instant: Instant,
) -> (TimerFuture<impl Future<Output = TimeResponse>>, TimerId)
pub fn notify_at_async( &self, instant: Instant, ) -> (TimerFuture<impl Future<Output = TimeResponse>>, TimerId)
Ask to receive a notification when the specified Instant
has arrived.
This is an async call to use with [crux_core::compose::Compose
].
Sourcepub fn notify_after<F>(&self, duration: Duration, callback: F) -> TimerId
pub fn notify_after<F>(&self, duration: Duration, callback: F) -> TimerId
Ask to receive a notification when the specified duration has elapsed.
Sourcepub fn notify_after_async(
&self,
duration: Duration,
) -> (TimerFuture<impl Future<Output = TimeResponse>>, TimerId)
pub fn notify_after_async( &self, duration: Duration, ) -> (TimerFuture<impl Future<Output = TimeResponse>>, TimerId)
Ask to receive a notification when the specified duration has elapsed.
This is an async call to use with [crux_core::compose::Compose
].