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