Struct crux_time::Time

source ·
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,

source

pub fn new(context: CapabilityContext<TimeRequest, Ev>) -> Self

source

pub fn now<F>(&self, callback: F)
where F: FnOnce(TimeResponse) -> Ev + Send + Sync + 'static,

Request current time, which will be passed to the app as a TimeResponse containing an Instant wrapped in the event produced by the callback.

source

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.

source

pub fn notify_at<F>(&self, instant: Instant, callback: F)
where F: FnOnce(TimeResponse) -> Ev + Send + Sync + 'static,

Ask to receive a notification when the specified Instant has arrived.

source

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.

source

pub fn notify_after<F>(&self, duration: Duration, callback: F)
where F: FnOnce(TimeResponse) -> Ev + Send + Sync + 'static,

Ask to receive a notification when the specified duration has elapsed.

source

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.

Trait Implementations§

source§

impl<Ev> Capability<Ev> for Time<Ev>

§

type Operation = TimeRequest

§

type MappedSelf<MappedEv> = Time<MappedEv>

source§

fn map_event<F, NewEv>(&self, f: F) -> Self::MappedSelf<NewEv>
where F: Fn(NewEv) -> Ev + Send + Sync + 'static, Ev: 'static, NewEv: 'static,

source§

impl<Ev> Clone for Time<Ev>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<Ev> Freeze for Time<Ev>

§

impl<Ev> !RefUnwindSafe for Time<Ev>

§

impl<Ev> Send for Time<Ev>

§

impl<Ev> Sync for Time<Ev>

§

impl<Ev> Unpin for Time<Ev>

§

impl<Ev> !UnwindSafe for Time<Ev>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.