[][src]Crate gain

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.

Modules

catalog

Programmer-readable catalog of available services.

error

Common error types.

identity

Identity information for this execution context.

origin

Communicate with the invoker of the program instance.

peer

Communicate with other program instances.

peerindex

Find other program instances.

service

Service binding implementation support.

stream

I/O streams.

task

Types and traits for working with asynchronous tasks.