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::AsyncReadandfutures_io::AsyncWrite. - tokio
- Adapters for
tokio::io::AsyncReadandtokio::io::AsyncWrite.
Traits§
- Async
Read - An async source of bytes.
- Async
Write - 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_lenbytes. - 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.