#await #framework #gate #runtime #webassembly

gain

Async/await-based framework for programs targetting Gate runtime (wasm32 targets)

7 releases (4 breaking)

Uses new Rust 2021

0.5.0 Dec 27, 2021
0.4.1 Jun 12, 2021
0.4.0 Mar 6, 2021
0.3.0 Nov 6, 2020
0.1.0 Dec 2, 2018

#282 in WebAssembly

Download history 9/week @ 2022-01-25 2/week @ 2022-02-01 4/week @ 2022-02-08 7/week @ 2022-02-15 12/week @ 2022-02-22 6/week @ 2022-03-01 4/week @ 2022-03-08 28/week @ 2022-03-15 39/week @ 2022-03-22 17/week @ 2022-03-29 13/week @ 2022-04-05 6/week @ 2022-04-12 10/week @ 2022-04-19 48/week @ 2022-04-26 33/week @ 2022-05-03 12/week @ 2022-05-10

103 downloads per month
Used in 3 crates

MIT license

84KB
2.5K SLoC


lib.rs:

Gate interface

Asynchronous execution

The task module provides a framework for spawning and running asynchronous tasks.

A typical program runs a single top-level task:

use gain::task::{block_on, spawn};

fn main() {
    block_on(async {
        spawn(concurrent_work());
        do_something().await;
    })
}

async fn concurrent_work() {
    do_stuff().await;
}

Concurrency is achieved by spawning more tasks. The program exits when the top-level task returns.

Service APIs

The catalog, identity, origin, peer and peerindex modules provide access to the built-in Gate services.

Common I/O stream types are defined in the stream module.

Service implementation

Additional service bindings can be implemented using the service module.

Dependencies

~200KB