async_io_mini/
lib.rs

1//! Async I/O for the ESP IDF (and possibly other MCU RTOSes supporting the [select] call and BSD Sockets).
2//!
3//! This crate provides [`Async`], an adapter for standard networking types (and [many other] types) to use in
4//! async programs.
5//!
6//! # Implementation
7//!
8//! The first time [`Async`] is used, a thread called "async-io-mini" will be spawned.
9//! The purpose of this thread is to wait for I/O events reported by the OS, and then
10//! wake appropriate futures blocked on I/O when they can be resumed.
11//!
12//! To wait for the next I/O event, the task uses the [select] syscall available on many operating systems.
13//!
14//! # Examples
15//!
16//! Connect to `example.com:80`.
17//!
18//! ```
19//! use async_io_mini::Async;
20//!
21//! use std::net::{TcpStream, ToSocketAddrs};
22//!
23//! # futures_lite::future::block_on(async {
24//! let addr = "example.com:80".to_socket_addrs()?.next().unwrap();
25//!
26//! let stream = Async::<TcpStream>::connect(addr).await?;
27//! # std::io::Result::Ok(()) });
28//! ```
29
30#![allow(unknown_lints)]
31#![allow(clippy::needless_maybe_sized)]
32
33pub use io::*;
34#[cfg(feature = "embassy-time")]
35pub use timer::*;
36
37mod io;
38mod reactor;
39mod sys;
40#[cfg(feature = "embassy-time")]
41mod timer;