use std::borrow::Cow;
use serialport::Result;
pub use serialport::{FlowControl, SerialPort};
use crate::BaudRate;
#[cfg(unix)]
type NativeSerialPort = serialport::TTYPort;
#[cfg(windows)]
type NativeSerialPort = serialport::COMPort;
pub fn open<'a>(
path: impl Into<Cow<'a, str>>,
baud_rate: BaudRate,
flow_control: FlowControl,
) -> Result<NativeSerialPort> {
serialport::new(path, baud_rate.into())
.flow_control(flow_control)
.open_native()
}
pub trait TryCloneNative: Sized {
fn try_clone_native(&self) -> Result<Self>;
}
impl TryCloneNative for NativeSerialPort {
fn try_clone_native(&self) -> Result<Self> {
Self::try_clone_native(self)
}
}