Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors = [
"Jesse Braham <jesse@beta7.io>",
]
edition = "2021"
rust-version = "1.59.0"
rust-version = "1.71.0"
description = "A cross-platform low-level serial port library."
documentation = "https://docs.rs/serialport"
repository = "https://github.com/serialport/serialport-rs"
Expand All @@ -15,7 +15,9 @@ keywords = ["serial", "hardware", "system", "RS232"]
categories = ["hardware-support"]

[target."cfg(unix)".dependencies]
async-io = { version = "2.6.0", optional = true }
bitflags = "2.4.0"
blocking = { version = "1.6.2", optional = true }
nix = { version = "0.26", default-features = false, features = ["fs", "ioctl", "poll", "signal", "term"] }

[target.'cfg(all(target_os = "linux", not(target_env = "musl")))'.dependencies]
Expand Down Expand Up @@ -46,6 +48,7 @@ features = [

[dependencies]
cfg-if = "1.0.0"
futures-io = { version = "0.3.31", optional = true }
scopeguard = "1.1"
serde = { version = "1.0", features = ["derive"], optional = true }

Expand All @@ -56,11 +59,7 @@ quote = ">=1, <=1.0.40"
assert_hex = "0.4.1"
clap = { version = "3.1.6", features = ["derive"] }
envconfig = "0.10.0"
# TODES Remove pinning this subdependency (of clap) when we are bumping our
# MSRV (libc raised its MSRV with a patch release 0.2.167 from 1.19.0 to
# 1.63.0). Trick the resolver into picking a compatible release of libc by
# adding it as a direct dependency meanwhile.
libc = ">=0.2.0, <=0.2.163"
libc = "0.2"
# TODO: Remove pinning this subdependency of clap when we are bumping our MSRV.
# (There has been an incompatible change with the MSRV of os_str_bytes with
# 6.6.0) Until then we are tricking the dependency resolver into using a
Expand All @@ -74,6 +73,7 @@ rustversion = "1.0.16"

[features]
default = ["libudev"]
async = ["dep:futures-io", "dep:async-io", "dep:blocking"]
hardware-tests = []
# TODO: Make the feature unconditionally available with the next major release
# (5.0) and remove this feature gate.
Expand Down
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ use std::time::Duration;

#[cfg(unix)]
mod posix;
#[cfg(all(unix, feature = "async"))]
pub use posix::AsyncSerialPort;
#[cfg(unix)]
pub use posix::{BreakDuration, TTYPort};

Expand Down Expand Up @@ -442,6 +444,12 @@ impl SerialPortBuilder {
pub fn open_native(self) -> Result<COMPort> {
windows::COMPort::open(&self)
}

/// Open a runtime-agnostic asynchronous interface to the port with the specified settings.
#[cfg(all(unix, feature = "async"))]
pub fn open_async(self) -> Result<AsyncSerialPort> {
AsyncSerialPort::open(&self)
}
}

/// A trait for serial port devices
Expand Down
Loading
Loading