1//! A small and fast async runtime.
2//!
3//! This crate simply re-exports other smaller async crates (see the source).
4//!
5//! To use tokio-based libraries with smol, apply the [`async-compat`] adapter to futures and I/O
6//! types.
7//!
8//! # Examples
9//!
10//! Connect to an HTTP website, make a GET request, and pipe the response to the standard output:
11//!
12//! ```
13//! use smol::{io, net, prelude::*, Unblock};
14//!
15//! fn main() -> io::Result<()> {
16//! smol::block_on(async {
17//! let mut stream = net::TcpStream::connect("example.com:80").await?;
18//! let req = b"GET / HTTP/1.1\r\nHost: example.com\r\nConnection: close\r\n\r\n";
19//! stream.write_all(req).await?;
20//!
21//! let mut stdout = Unblock::new(std::io::stdout());
22//! io::copy(stream, &mut stdout).await?;
23//! Ok(())
24//! })
25//! }
26//! ```
27//!
28//! There's a lot more in the [examples] directory.
29//!
30//! [`async-compat`]: https://docs.rs/async-compat
31//! [examples]: https://github.com/smol-rs/smol/tree/master/examples
32//! [get-request]: https://github.com/smol-rs/smol/blob/master/examples/get-request.rs
33
34#![doc(
35 html_favicon_url = "https://raw.githubusercontent.com/smol-rs/smol/master/assets/images/logo_fullsize_transparent.png"
36)]
37#![doc(
38 html_logo_url = "https://raw.githubusercontent.com/smol-rs/smol/master/assets/images/logo_fullsize_transparent.png"
39)]
40#![forbid(unsafe_code)]
41#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]
42
43#[cfg(doctest)]
44doc_comment::doctest!("../README.md");
45
46#[doc(inline)]
47pub use {
48 async_executor::{Executor, LocalExecutor, Task},
49 async_io::{block_on, Async, Timer},
50 blocking::{unblock, Unblock},
51 futures_lite::{future, io, pin, prelude, ready, stream},
52};
53
54#[doc(inline)]
55pub use {async_channel as channel, async_fs as fs, async_lock as lock, async_net as net};
56
57#[cfg(not(target_os = "espidf"))]
58#[doc(inline)]
59pub use async_process as process;
60
61mod spawn;
62pub use spawn::spawn;
63