msrt-std 0.1.0

std byte-stream adapters for MSRT.
Documentation
  • Coverage
  • 100%
    11 out of 11 items documented0 out of 0 items with examples
  • Size
  • Source code size: 14.78 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 894.48 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 3s Average build duration of successful builds.
  • all releases: 3s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • atlas-orien/msrt-adapters
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • atlas-orien

msrt-std

Blocking std byte-stream adapters for MSRT.

This crate is for host-side Rust programs that already own a byte stream:

  • serial ports
  • TCP streams
  • pipes
  • test doubles implementing Read + Write

The first version provides:

  • StdFrontend<T>: active client/frontend endpoint
  • StdBackend<T>: passive single-peer backend endpoint

T only needs to implement std::io::Read + std::io::Write.

Basic Frontend

use msrt_std::{AdapterEvent, StdFrontend};

# fn run<T: std::io::Read + std::io::Write>(io: T) -> msrt_std::Result<()> {
let mut frontend = StdFrontend::new(io);
frontend.connect()?;
frontend.send(b"hello")?;

loop {
    match frontend.tick()? {
        AdapterEvent::Message(message) => {
            println!("{:?}", message.as_bytes());
        }
        AdapterEvent::SendFailed(_) => {
            frontend.disconnect();
        }
        AdapterEvent::Idle => {}
    }
}
# }

Use nonblocking IO when calling receive_available or tick; WouldBlock is treated as "no input right now".