Crates.io | wasmcloud-interface-timing |
lib.rs | wasmcloud-interface-timing |
version | 0.1.2 |
source | src |
created_at | 2023-04-18 16:39:54.755769 |
updated_at | 2023-05-02 16:45:50.023905 |
description | Interface for actors to perform time related operations |
homepage | |
repository | https://github.com/wasmcloud/examples |
max_upload_size | |
id | 842622 |
size | 7,695 |
Interface definition for the "wasmcloud:timing" capability contract. This contract allows actors to retrieve the current system time on the wasmcloud host.
The Timestamp
struct has nanosecond precision, so if it will be exposed to
users at any point, care should be taken to avoid timing attacks by truncating
the nsec
field or to setting it to 0
.
The default implementation of this capability contract truncates the Timestamp
to millisecond precision, but it may be necessary to reduce the precision even
further.
use wasmcloud_interface_timing::TimingSender;
use wasmbus_rpc::actor::prelude::*;
use wasmbus_rpc::Timestamp;
async fn get_current_time(ctx: &Context) -> RpcResult<Timestamp> {
let timing = TimingSender::new();
timing.now(ctx).await
}