Skip to main content

Crate async_io_mini

Crate async_io_mini 

Source
Expand description

Async I/O for the ESP IDF (and possibly other MCU RTOSes supporting the [select] call and BSD Sockets).

This crate provides Async, an adapter for standard networking types (and [many other] types) to use in async programs.

§Implementation

The first time Async is used, a thread called “async-io-mini” will be spawned. The purpose of this thread is to wait for I/O events reported by the OS, and then wake appropriate futures blocked on I/O when they can be resumed. Its stack is REACTOR_STACK_SIZE bytes, selectable with the stack-size-* features.

Note that “async-io-mini” is the Rust-level thread name. On the ESP IDF the name of the underlying RTOS task is taken from esp_pthread_cfg_t rather than from the Rust thread name, so the reactor shows up as “pthread” in panic reports and task dumps.

To wait for the next I/O event, the task uses the [select] syscall available on many operating systems.

§Examples

Connect to example.com:80.

use async_io_mini::Async;

use std::net::{TcpStream, ToSocketAddrs};

let addr = "example.com:80".to_socket_addrs()?.next().unwrap();

let stream = Async::<TcpStream>::connect(addr).await?;

Macros§

ready
syscall
syscall_los
syscall_los_eagain

Structs§

Async
Async adapter for I/O types.
Timer
A future or stream that emits timed events.

Constants§

REACTOR_STACK_SIZE
The size (in bytes) of the stack of the reactor thread.

Traits§

IoSafe
Types whose I/O trait implementations do not drop the underlying I/O source.