Struct mio_serial::SerialStream [−][src]
pub struct SerialStream { /* fields omitted */ }
Expand description
SerialStream
Implementations
Open a nonblocking serial port from the provided builder
Example
use std::path::Path; let path = "/dev/ttyUSB0"; let serial = SerialStream::open(path, 9600).unwrap();
Create a pair of pseudo serial terminals
Returns
Two connected Serial
objects: (master, slave)
Errors
Attempting any IO or parameter settings on the slave tty after the master tty is closed will return errors.
Examples
use mio_serial::SerialStream; let (master, slave) = SerialStream::pair().unwrap();
Sets the exclusivity of the port
If a port is exclusive, then trying to open the same device path again will fail.
See the man pages for the tiocexcl and tiocnxcl ioctl’s for more details.
Errors
Io
for any error while setting exclusivity for the port.
Trait Implementations
Constructs a new instance of Self
from the given raw file
descriptor. Read more
Consumes this object, returning the raw underlying file descriptor. Read more
Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more
Like read
, except that it reads into a slice of buffers. Read more
can_vector
)Determines if this Read
er has an efficient read_vectored
implementation. Read more
read_initializer
)Determines if this Read
er can work with buffers of uninitialized
memory. Read more
Read all bytes until EOF in this source, placing them into buf
. Read more
Read all bytes until EOF in this source, appending them to buf
. Read more
Read the exact number of bytes required to fill buf
. Read more
Creates a “by reference” adaptor for this instance of Read
. Read more
Creates an adaptor which will chain this stream with another. Read more
Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more
Like read
, except that it reads into a slice of buffers. Read more
can_vector
)Determines if this Read
er has an efficient read_vectored
implementation. Read more
read_initializer
)Determines if this Read
er can work with buffers of uninitialized
memory. Read more
Read all bytes until EOF in this source, placing them into buf
. Read more
Read all bytes until EOF in this source, appending them to buf
. Read more
Read the exact number of bytes required to fill buf
. Read more
Creates a “by reference” adaptor for this instance of Read
. Read more
Creates an adaptor which will chain this stream with another. Read more
Returns the current baud rate.
This function returns None
if the baud rate could not be determined. This may occur if
the hardware is in an uninitialized state. Setting a baud rate with set_baud_rate()
should initialize the baud rate to a supported value.
Returns the character size.
This function returns None
if the character size could not be determined. This may occur
if the hardware is in an uninitialized state or is using a non-standard character size.
Setting a baud rate with set_char_size()
should initialize the character size to a
supported value.
Returns the flow control mode.
This function returns None
if the flow control mode could not be determined. This may
occur if the hardware is in an uninitialized state or is using an unsupported flow control
mode. Setting a flow control mode with set_flow_control()
should initialize the flow
control mode to a supported value.
Returns the parity-checking mode.
This function returns None
if the parity mode could not be determined. This may occur if
the hardware is in an uninitialized state or is using a non-standard parity mode. Setting
a parity mode with set_parity()
should initialize the parity mode to a supported value.
Returns the number of stop bits.
This function returns None
if the number of stop bits could not be determined. This may
occur if the hardware is in an uninitialized state or is using an unsupported stop bit
configuration. Setting the number of stop bits with set_stop-bits()
should initialize the
stop bits to a supported value.
Returns the current timeout. This parameter is const and equal to zero and implemented due to required for trait completeness.
Sets the baud rate.
Errors
If the implementation does not support the requested baud rate, this function may return an
InvalidInput
error. Even if the baud rate is accepted by set_baud_rate()
, it may not be
supported by the underlying hardware.
Sets the character size.
Sets the flow control mode.
Sets the parity-checking mode.
Sets the number of stop bits.
Sets the timeout for future I/O operations. This parameter is ignored but required for trait completeness.
Sets the state of the RTS (Request To Send) control signal.
Setting a value of true
asserts the RTS control signal. false
clears the signal.
Errors
This function returns an error if the RTS control signal could not be set to the desired state on the underlying hardware:
NoDevice
if the device was disconnected.Io
for any other type of I/O error.
Writes to the Data Terminal Ready pin
Setting a value of true
asserts the DTR control signal. false
clears the signal.
Errors
This function returns an error if the DTR control signal could not be set to the desired state on the underlying hardware:
NoDevice
if the device was disconnected.Io
for any other type of I/O error.
Reads the state of the CTS (Clear To Send) control signal.
This function returns a boolean that indicates whether the CTS control signal is asserted.
Errors
This function returns an error if the state of the CTS control signal could not be read from the underlying hardware:
NoDevice
if the device was disconnected.Io
for any other type of I/O error.
Reads the state of the Data Set Ready control signal.
This function returns a boolean that indicates whether the DSR control signal is asserted.
Errors
This function returns an error if the state of the DSR control signal could not be read from the underlying hardware:
NoDevice
if the device was disconnected.Io
for any other type of I/O error.
Reads the state of the Ring Indicator control signal.
This function returns a boolean that indicates whether the RI control signal is asserted.
Errors
This function returns an error if the state of the RI control signal could not be read from the underlying hardware:
NoDevice
if the device was disconnected.Io
for any other type of I/O error.
Reads the state of the Carrier Detect control signal.
This function returns a boolean that indicates whether the CD control signal is asserted.
Errors
This function returns an error if the state of the CD control signal could not be read from the underlying hardware:
NoDevice
if the device was disconnected.Io
for any other type of I/O error.
Gets the number of bytes available to be read from the input buffer.
Errors
This function may return the following errors:
NoDevice
if the device was disconnected.Io
for any other type of I/O error.
Get the number of bytes written to the output buffer, awaiting transmission.
Errors
This function may return the following errors:
NoDevice
if the device was disconnected.Io
for any other type of I/O error.
Discards all bytes from the serial driver’s input buffer and/or output buffer.
Errors
This function may return the following errors:
NoDevice
if the device was disconnected.Io
for any other type of I/O error.
Cloning is not supported for SerialStream objects
This logic has never really completely worked. Cloned file descriptors in asynchronous code is a semantic minefield. Are you cloning the file descriptor? Are you cloning the event flags on the file descriptor? Both? It’s a bit of a mess even within one OS, let alone across multiple OS’s
Maybe it can be done with more work, but until a clear use-case is required (or mio/tokio
gets an equivalent of the unix AsyncFd
for async file handles, see
https://github.com/tokio-rs/tokio/issues/3781 and
https://github.com/tokio-rs/tokio/pull/3760#issuecomment-839854617) I would rather not
have any code available over a kind-of-works-maybe impl. So I’ll leave this code here
for now but hard-code it disabled.
Stop transmitting a break
Register self
with the given Registry
instance. Read more
fn reregister(
&mut self,
registry: &Registry,
token: Token,
interests: Interest
) -> StdIoResult<()>
fn reregister(
&mut self,
registry: &Registry,
token: Token,
interests: Interest
) -> StdIoResult<()>
Re-register self
with the given Registry
instance. Read more
Deregister self
from the given Registry
instance. Read more
Write a buffer into this writer, returning how many bytes were written. Read more
Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
can_vector
)Determines if this Write
r has an efficient write_vectored
implementation. Read more
Attempts to write an entire buffer into this writer. Read more
write_all_vectored
)Attempts to write multiple buffers into this writer. Read more
Writes a formatted string into this writer, returning any error encountered. Read more
Write a buffer into this writer, returning how many bytes were written. Read more
Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
can_vector
)Determines if this Write
r has an efficient write_vectored
implementation. Read more
Attempts to write an entire buffer into this writer. Read more
write_all_vectored
)Attempts to write multiple buffers into this writer. Read more
Writes a formatted string into this writer, returning any error encountered. Read more
Auto Trait Implementations
impl RefUnwindSafe for SerialStream
impl Send for SerialStream
impl Sync for SerialStream
impl Unpin for SerialStream
impl UnwindSafe for SerialStream