Skip to main content

Module io

Module io 

Source
Available on crate feature std only.
Expand description

std::io::Read / std::io::Write integration: the streaming Tier-2 encoder and decoder pair, plus convenience free functions.

This module is gated on the std feature (on by default). With std off, the crate compiles for no_std targets using core + alloc only and none of this module is reachable.

§When to use which entry point

  • For one-shot send / receive of a single value, prefer encode_into / decode_from: they take any Write / Read and handle the buffering.
  • For interleaved writes / reads across many values without per-value allocation, instantiate an IoEncoder / IoDecoder and call write / read repeatedly.

§Errors

Both directions surface I/O failure through the codec’s crate::SerialError type via SerialError::Io. The Io variant captures std::io::ErrorKind and a message string — enough to surface the original cause without taking on a non-Clone payload.

Structs§

IoDecoder
Streaming decoder that reads directly from any Read-shaped source.
IoEncoder
Streaming encoder that writes directly into any Write-shaped sink.

Functions§

decode_from
Read all remaining bytes from reader and decode them as a single value of type T.
encode_into
Encode value and write the result into writer in a single call.