Skip to main content

Module async_io

Module async_io 

Source
Expand description

Async helpers for complete CBOR item I/O.

Serde deserialization is synchronous, so this module does not try to make serde itself resumable. Instead it solves the practical async socket use case: read exactly one complete CBOR item into bytes, or write one complete item out, then hand those bytes to the regular from_slice and to_vec APIs.

Enable the futures or tokio crate features to use the adapters in the async_io::futures or async_io::tokio modules.

The item walk is iterative, so the futures returned here are plain state machines: when the reader or writer is Send, so is the future, and it can be driven by multi-threaded executors such as tokio::spawn.

Modules§

futures
Adapters for futures_io::AsyncRead and futures_io::AsyncWrite.
tokio
Adapters for tokio::io::AsyncRead and tokio::io::AsyncWrite.

Traits§

AsyncRead
An async source of bytes.
AsyncWrite
An async sink for bytes.

Functions§

read_item
Reads one complete, well-formed CBOR item from an async reader.
read_item_with_limit
Reads one complete, well-formed CBOR item from an async reader, rejecting items larger than max_len bytes.
read_value
Reads one complete CBOR item and deserializes it into an owned value.
read_value_with_limit
Reads one bounded CBOR item and deserializes it into an owned value.
write_item
Writes one already-encoded CBOR item to an async writer.
write_value
Serializes a value to one CBOR item and writes it to an async writer.