Struct ferrous_serialport::COMPort [−][src]
pub struct COMPort { /* fields omitted */ }
A serial port implementation for Windows COM ports
The port will be closed when the value is dropped. However, this struct
should not be instantiated directly by using COMPort::open()
, instead use
the cross-platform serialport::open()
or
serialport::open_with_settings()
.
Implementations
impl COMPort
[src]
impl COMPort
[src]pub fn open(builder: &SerialPortBuilder) -> Result<COMPort>
[src]
Opens a COM port as a serial device.
port
should be the name of a COM port, e.g., COM1
.
If the COM port handle needs to be opened with special flags, use
from_raw_handle
method to create the COMPort
. Note that you should
set the different settings before using the serial port using set_all
.
Errors
NoDevice
if the device could not be opened. This could indicate that the device is already in use.InvalidInput
ifport
is not a valid device name.Io
for any other I/O error while opening or initializing the device.
pub fn try_clone_native(&self) -> Result<COMPort>
[src]
Attempts to clone the SerialPort
. This allow you to write and read simultaneously from the
same serial connection. Please note that if you want a real asynchronous serial port you
should look at mio-serial or
tokio-serial.
Also, you must be very careful when changing the settings of a cloned SerialPort
: since
the settings are cached on a per object basis, trying to modify them from two different
objects can cause some nasty behavior.
This is the same as SerialPort::try_clone()
but returns the concrete type instead.
Errors
This function returns an error if the serial port couldn’t be cloned.
Trait Implementations
impl AsRawHandle for COMPort
[src]
impl AsRawHandle for COMPort
[src]fn as_raw_handle(&self) -> RawHandle
[src]
impl FromRawHandle for COMPort
[src]
impl FromRawHandle for COMPort
[src]unsafe fn from_raw_handle(handle: RawHandle) -> Self
[src]
impl Read for COMPort
[src]
impl Read for COMPort
[src]fn read(&mut self, buf: &mut [u8]) -> Result<usize>
[src]
pub fn read_vectored(
&mut self,
bufs: &mut [IoSliceMut<'_>]
) -> Result<usize, Error>
1.36.0[src]
&mut self,
bufs: &mut [IoSliceMut<'_>]
) -> Result<usize, Error>
pub fn is_read_vectored(&self) -> bool
[src]
pub unsafe fn initializer(&self) -> Initializer
[src]
pub fn read_to_end(&mut self, buf: &mut Vec<u8, Global>) -> Result<usize, Error>
1.0.0[src]
pub fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
1.0.0[src]
pub fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
1.6.0[src]
pub fn by_ref(&mut self) -> &mut Self
1.0.0[src]
pub fn bytes(self) -> Bytes<Self>
1.0.0[src]
pub fn chain<R>(self, next: R) -> Chain<Self, R> where
R: Read,
1.0.0[src]
R: Read,
pub fn take(self, limit: u64) -> Take<Self>
1.0.0[src]
impl SerialPort for COMPort
[src]
impl SerialPort for COMPort
[src]fn name(&self) -> Option<String>
[src]
fn timeout(&self) -> Duration
[src]
fn set_timeout(&mut self, timeout: Duration) -> Result<()>
[src]
fn write_request_to_send(&mut self, level: bool) -> Result<()>
[src]
fn write_data_terminal_ready(&mut self, level: bool) -> Result<()>
[src]
fn read_clear_to_send(&mut self) -> Result<bool>
[src]
fn read_data_set_ready(&mut self) -> Result<bool>
[src]
fn read_ring_indicator(&mut self) -> Result<bool>
[src]
fn read_carrier_detect(&mut self) -> Result<bool>
[src]
fn baud_rate(&self) -> Result<u32>
[src]
fn data_bits(&self) -> Result<DataBits>
[src]
fn parity(&self) -> Result<Parity>
[src]
fn stop_bits(&self) -> Result<StopBits>
[src]
fn flow_control(&self) -> Result<FlowControl>
[src]
fn set_baud_rate(&mut self, baud_rate: u32) -> Result<()>
[src]
fn set_data_bits(&mut self, data_bits: DataBits) -> Result<()>
[src]
fn set_parity(&mut self, parity: Parity) -> Result<()>
[src]
fn set_stop_bits(&mut self, stop_bits: StopBits) -> Result<()>
[src]
fn set_flow_control(&mut self, flow_control: FlowControl) -> Result<()>
[src]
fn bytes_to_read(&self) -> Result<u32>
[src]
fn bytes_to_write(&self) -> Result<u32>
[src]
fn clear(&self, buffer_to_clear: ClearBuffer) -> Result<()>
[src]
fn try_clone(&self) -> Result<Box<dyn SerialPort>>
[src]
fn set_break(&self) -> Result<()>
[src]
fn clear_break(&self) -> Result<()>
[src]
impl Write for COMPort
[src]
impl Write for COMPort
[src]fn write(&mut self, buf: &[u8]) -> Result<usize>
[src]
fn flush(&mut self) -> Result<()>
[src]
pub fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize, Error>
1.36.0[src]
pub fn is_write_vectored(&self) -> bool
[src]
pub fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
1.0.0[src]
pub fn write_all_vectored(
&mut self,
bufs: &mut [IoSlice<'_>]
) -> Result<(), Error>
[src]
&mut self,
bufs: &mut [IoSlice<'_>]
) -> Result<(), Error>
pub fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<(), Error>
1.0.0[src]
pub fn by_ref(&mut self) -> &mut Self
1.0.0[src]
Auto Trait Implementations
impl RefUnwindSafe for COMPort
impl RefUnwindSafe for COMPort
impl UnwindSafe for COMPort
impl UnwindSafe for COMPort