wasmcloud_interface_sleepy

Trait Sleepy

Source
pub trait Sleepy {
    // Required methods
    fn sleep<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        ctx: &'life1 Context,
        arg: &'life2 u32,
    ) -> Pin<Box<dyn Future<Output = RpcResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn sleep_until<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        ctx: &'life1 Context,
        arg: &'life2 Timestamp,
    ) -> Pin<Box<dyn Future<Output = RpcResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    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

Allows actors to sleep for a specified duration, or until a desired time. contractId: “jclmnop:sleepy” wasmbus.contractId: jclmnop:sleepy wasmbus.providerReceive

Required Methods§

Source

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

Sleep for a specified number of milliseconds

let sleepy = SleepySender::new();
// sleep for 5 seconds
sleepy.sleep(ctx, &5000).await?;
Source

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

Sleep until a specified time, provided as a wasmbus_rpc::Timestamp struct. If the specified time is in the past, the operation will return immediately.

let sleepy = SleepySender::new();
let now = sleepy.now(ctx).await?;
let five_seconds = Timestamp::new(now.sec + 5, now.nsec);
// sleep until 5 seconds from now
sleepy.sleep_until(ctx, &five_seconds).await
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.

let sleepy = SleepySender::new();
let now = sleepy.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§