Skip to main content

Module adapters

Module adapters 

Source
Available on crate features blocking or tokio or serial only.
Expand description

Optional I/O adapters that wrap the sans-I/O core into convenience APIs.

The crate’s core (session, file_transfer, codec) does no I/O of its own — callers feed bytes in and pull events out. These adapter modules lift that core over a real transport. Each is gated behind its own feature flag so users only pay for what they use:

  • blocking (feature blocking) — synchronous loop over any std::io::Read + std::io::Write transport.
  • tokio (feature tokio) — async loop over any tokio::io::AsyncRead + AsyncWrite + Unpin transport.
  • serialport (feature serial) — convenience helpers for opening a serialport::SerialPort, which already implements Read + Write and so plugs into blocking directly.

Custom transports — TCP-to-serial bridges, USB CDC via rusb, in-memory pipes for tests — just need to implement those standard traits.

Shared option / result / error types live in common.

Modules§

blockingblocking
Synchronous adapter — drives the sans-I/O core over a Read + Write transport.
commonblocking or tokio
Shared types used by both the blocking and tokio adapter modules.
serialportserial
Convenience integration with the serialport crate.
tokiotokio
Tokio async adapter — drives the sans-I/O core over an AsyncRead + AsyncWrite transport.