async_rs/lib.rs
1#![deny(missing_docs, missing_debug_implementations, unsafe_code)]
2#![allow(clippy::manual_async_fn)]
3
4//! A Rust async runtime abstration library.
5//!
6//! ## Features
7//!
8//! - tokio: enable the tokio implementation *(default)*
9//! - smol: enable the smol implementation
10//! - async-global-executor: enable the async-global-executor implementation
11//! - async-io: enable the async-io reactor implementation
12//!
13//! ## Example
14//!
15//! ```rust
16//! # #[cfg(feature="tokio")]
17//! # {
18//! use async_rs::{Runtime, TokioRuntime, traits::*};
19//! use std::{io, time::Duration};
20//!
21//! async fn get_a(rt: &TokioRuntime) -> io::Result<u32> {
22//! rt.spawn_blocking(|| Ok(12)).await
23//! }
24//!
25//! async fn get_b(rt: &TokioRuntime) -> io::Result<u32> {
26//! rt.spawn(async { Ok(30) }).await
27//! }
28//!
29//! async fn tokio_main(rt: &TokioRuntime) -> io::Result<()> {
30//! let a = get_a(rt).await?;
31//! let b = get_b(rt).await?;
32//! rt.sleep(Duration::from_millis(500)).await;
33//! assert_eq!(a + b, 42);
34//! Ok(())
35//! }
36//!
37//! fn main() -> io::Result<()> {
38//! let rt = Runtime::tokio()?;
39//! rt.block_on(tokio_main(&rt))
40//! }
41//! # }
42//! ```
43
44mod runtime;
45pub use runtime::*;
46
47pub mod traits;
48
49mod implementors;
50pub use implementors::*;
51
52pub mod util;
53
54mod sys;