Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

async-serial

Lightweight async serial port adapter — bridges [serialport] with [async-io].

Crates.io License

Quickstart

use async_serial::AsyncSerialPortBuilder as _;

let mut port = serialport::new("/dev/ttyUSB0", 9_600)
    .open_async()?;

// Async read — won't block the executor
let mut buf = [0u8; 256];
let n = port.read(&mut buf).await?;

How It Works

serialport::TTYPort / serialport::COMPort implement Read + Write but those are blocking calls. async-io provides an Async<T> wrapper that makes any IoSafe + AsFd type non-blocking via the reactor.

This crate provides:

  • IoSafeAdapter<T> — a newtype that supplies the missing IoSafe and AsFd impls
  • AsyncSerialPort — a type alias for Async<IoSafeAdapter<platform port>>
  • AsyncSerialPortBuilder — an extension trait that adds .open_async() to SerialPortBuilder

Platform Support

Platform Backend type
Unix TTYPort
Windows COMPort

License

MIT OR Apache-2.0

About

Lightweight async serial port adapter for serial and async-io crates.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages