Skip to content
Open
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
2 changes: 1 addition & 1 deletion examples/read_serialport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pub fn main() -> io::Result<()> {
// This should never happen as we only registered our
// `UdpSocket` using the `UDP_SOCKET` token, but if it ever
// does we'll log it.
error!("Got event for unexpected token: {:?}", event);
error!("Got event for unexpected token: {event:?}");
}
}
}
Expand Down
8 changes: 3 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ mod os_prelude {
pub use winapi::um::fileapi::*;
pub use winapi::um::handleapi::INVALID_HANDLE_VALUE;
pub use winapi::um::winbase::{COMMTIMEOUTS, FILE_FLAG_OVERLAPPED};
pub use winapi::um::winnt::{
FILE_ATTRIBUTE_NORMAL, GENERIC_READ, GENERIC_WRITE, HANDLE,
};
pub use winapi::um::winnt::{FILE_ATTRIBUTE_NORMAL, GENERIC_READ, GENERIC_WRITE, HANDLE};
}
use os_prelude::*;

Expand Down Expand Up @@ -668,7 +666,7 @@ mod io {
}
}

impl<'a> Read for &'a SerialStream {
impl Read for &SerialStream {
fn read(&mut self, bytes: &mut [u8]) -> StdIoResult<usize> {
uninterruptibly!(match unsafe {
libc::read(
Expand All @@ -683,7 +681,7 @@ mod io {
}
}

impl<'a> Write for &'a SerialStream {
impl Write for &SerialStream {
fn write(&mut self, bytes: &[u8]) -> StdIoResult<usize> {
uninterruptibly!(match unsafe {
libc::write(
Expand Down
15 changes: 6 additions & 9 deletions tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ pub fn checked_read(port: &mut mio_serial::SerialStream, data: &mut [u8], expect
pub struct Fixture {
#[cfg(unix)]
process: process::Child,
pub port_a: &'static str,
pub port_b: &'static str,
pub port_a: String,
pub port_b: String,
}

#[cfg(unix)]
Expand All @@ -200,14 +200,11 @@ impl Fixture {
pub fn new(port_a: &'static str, port_b: &'static str) -> Self {
use std::sync::atomic::{AtomicUsize, Ordering};
static N: AtomicUsize = AtomicUsize::new(0);
LOGGING_INIT.call_once(|| env_logger::init());
LOGGING_INIT.call_once(env_logger::init);
let n = N.fetch_add(1, Ordering::Relaxed);
let port_a = format!("{}{}", port_a, n).leak();
let port_b = format!("{}{}", port_b, n).leak();
let args = [
format!("PTY,link={}", port_a),
format!("PTY,link={}", port_b),
];
let port_a = format!("{port_a}{n}");
let port_b = format!("{port_b}{n}");
let args = [format!("PTY,link={port_a}"), format!("PTY,link={port_b}")];
log::trace!("starting process: socat {} {}", args[0], args[1]);

let process = process::Command::new("socat")
Expand Down
10 changes: 5 additions & 5 deletions tests/test_serialstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const TOKEN2: Token = Token(1);
fn test_builder_open_async() {
let fixture = common::setup_virtual_serial_ports();
let baud_rate = 9600;
let builder = mio_serial::new(fixture.port_a, baud_rate);
let builder = mio_serial::new(&*fixture.port_a, baud_rate);

let stream = builder
.open_native_async()
Expand All @@ -25,7 +25,7 @@ fn test_native_from_blocking() {
let baud_rate = 9600;

let fixture = common::setup_virtual_serial_ports();
let port = fixture.port_a;
let port = &*fixture.port_a;
let native_blocking = mio_serial::new(port, baud_rate)
.open_native()
.unwrap_or_else(|e| panic!("unable to open serial port {port}: {e}"));
Expand All @@ -40,7 +40,7 @@ fn test_native_from_blocking() {
fn test_stream_open() {
let baud_rate = 9600;
let fixture = common::setup_virtual_serial_ports();
let port = fixture.port_a;
let port = &*fixture.port_a;
let builder = mio_serial::new(port, baud_rate);
let stream = mio_serial::SerialStream::open(&builder).expect("unable to open serial port");

Expand All @@ -54,7 +54,7 @@ fn test_stream_open() {
fn test_port_enumeration() {
let fixture = common::setup_virtual_serial_ports();
let ports = mio_serial::available_ports().expect("unable to enumerate serial ports");
for name in [fixture.port_a, fixture.port_b] {
for name in [&*fixture.port_a, &*fixture.port_b] {
ports
.iter()
.find(|&info| info.port_name == *name)
Expand All @@ -73,7 +73,7 @@ fn test_read_write_pair() {
let baud_rate = 38400;

let fixture = common::setup_virtual_serial_ports();
let (port_a, port_b) = (fixture.port_a, fixture.port_b);
let (port_a, port_b) = (&*fixture.port_a, &*fixture.port_b);
let (mut poll, mut events) = common::init_with_poll();

let mut port_1 = mio_serial::new(port_a, baud_rate)
Expand Down
Loading