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)
pub fn notify_at<F>(&self, instant: Instant, callback: F)
Ask to receive a notification when the specified Instant
has arrived.
sourcepub async fn notify_at_async(&self, instant: Instant) -> TimeResponse
pub async fn notify_at_async(&self, instant: Instant) -> TimeResponse
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)
pub fn notify_after<F>(&self, duration: Duration, callback: F)
Ask to receive a notification when the specified duration has elapsed.
sourcepub async fn notify_after_async(&self, duration: Duration) -> TimeResponse
pub async fn notify_after_async(&self, duration: Duration) -> TimeResponse
Ask to receive a notification when the specified duration has elapsed.
This is an async call to use with crux_core::compose::Compose
.