wasmcloud_interface_timing

Trait Timing

Source
pub trait Timing {
    // Required method
    fn now<'life0, 'life1, 'async_trait>(
        &'life0 self,
        ctx: &'life1 Context,
    ) -> Pin<Box<dyn Future<Output = RpcResult<Timestamp>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided method
    fn contract_id() -> &'static str { ... }
}
Expand description

Provides the capability to read the system time. wasmbus.contractId: wasmcloud:timing wasmbus.providerReceive

Required Methods§

Source

fn now<'life0, 'life1, 'async_trait>( &'life0 self, ctx: &'life1 Context, ) -> Pin<Box<dyn Future<Output = RpcResult<Timestamp>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Returns the current time as a wasmbus_rpc::Timestamp struct.

The returned timestamp has nanosecond precision, so care should be taken to avoid timing attacks. If the timestamp will be made visible to users, it’s recommended to reduce the precision by truncating or removing the nsec field.

let timing = TimingSender::new();
let now = timing.now(ctx).await?;

Provided Methods§

Source

fn contract_id() -> &'static str

returns the capability contract id for this interface

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§