#wasmcloud #wasm #actor #webassembly #capability

wasmcloud-interface-numbergen

interface for actors to generate random numbers and guids (wasmcloud:builtin:numbergen)

15 releases (7 breaking)

0.8.1 Nov 23, 2022
0.7.0 Aug 16, 2022
0.6.1 Jul 18, 2022
0.5.0 Mar 1, 2022
0.1.0 Jul 23, 2021

#239 in WebAssembly

Download history 19/week @ 2022-11-26 26/week @ 2022-12-03 11/week @ 2022-12-10 34/week @ 2022-12-17 16/week @ 2022-12-24 25/week @ 2022-12-31 13/week @ 2023-01-07 8/week @ 2023-01-14 30/week @ 2023-01-21 42/week @ 2023-01-28 102/week @ 2023-02-04 78/week @ 2023-02-11 42/week @ 2023-02-18 28/week @ 2023-02-25 33/week @ 2023-03-04 71/week @ 2023-03-11

213 downloads per month

Apache-2.0 and maybe LGPL-3.0-or-later

14KB
234 lines

crates.io  TinyGo Version

wasmCloud Number Generator Interface

This is the interface definition for the wasmCloud built-in interface that is guaranteed to be supported by all runtime hosts, wasmcloud:builtin:numbergen. The number generator interface provides for the creation of things like random numbers, random numbers within a given range, and globally unique identifiers (GUIDs).

Capability Provider Implementations

There are no external implementations of this provider as all implementations of the wasmcloud:builtin:numbergen contract are built directly into the host runtime(s).

This interface defines the wasmCloud built-in logging interface that comes with each of our supported host runtimes. Actors that use this interface must have the capability contract wasmcloud:builtin:numbergen in their claims list (wash claims sign --cap wasmcloud:builtin:numbergen).

Example Usage (🦀 Rust)

use wasmbus_rpc::actor::prelude::*;
use wasmcloud_interface_logging::info;
use wasmcloud_interface_numbergen::{generate_guid, random_32, random_in_range};

async fn generate_random() -> Result<(), RpcError> {
    // Generate a Globally Unique ID (GUID)
    let guid: String = generate_guid().await?;
    info!("Generated GUID: {}", guid);
    // Generate a random u32
    let random_num: u32 = random_32().await?;
    info!("Generated number: {}", random_num);
    // Generate a random u32 within an inclusive range
    let random_range: u32 = random_in_range(0, 55).await?;
    info!("Generated number between 0 and 55: {}", random_range);
    Ok(())
}

Dependencies

~9–20MB
~406K SLoC