gain/
lib.rs

1// Copyright (c) 2018 Timo Savola.
2// Use of this source code is governed by the MIT
3// license that can be found in the LICENSE file.
4
5//! # Gate interface
6//!
7//! ## Asynchronous execution
8//!
9//! The [`task`](task) module provides a framework for spawning and running
10//! asynchronous tasks.
11//!
12//! A typical program runs a single top-level task:
13//!
14//! ```
15//! use gain::task::{block_on, spawn};
16//!
17//! fn main() {
18//!     block_on(async {
19//!         spawn(concurrent_work());
20//!         do_something().await;
21//!     })
22//! }
23//!
24//! async fn concurrent_work() {
25//!     do_stuff().await;
26//! }
27//! ```
28//!
29//! Concurrency is achieved by spawning more tasks.  The program exits when the
30//! top-level task returns.
31//!
32//! ## Service APIs
33//!
34//! The [`catalog`](catalog), [`identity`](identity), [`origin`](origin),
35//! [`peer`](peer) and [`peerindex`](peerindex) modules provide access to the
36//! built-in Gate services.
37//!
38//! Common I/O stream types are defined in the [`stream`](stream) module.
39//!
40//! ## Service implementation
41//!
42//! Additional service bindings can be implemented using the
43//! [`service`](service) module.
44
45#[macro_use]
46extern crate lazy_static;
47
48pub mod catalog;
49mod core;
50mod gate;
51pub mod identity;
52pub mod origin;
53mod packet;
54pub mod peer;
55pub mod peerindex;
56pub mod service;
57pub mod stream;
58pub mod task;
59mod threadunsafe;