[][src]Struct serialport::posix::TTYPort

pub struct TTYPort { /* fields omitted */ }

A TTY-based serial port implementation.

The port will be closed when the value is dropped. However, this struct should not be instantiated directly by using TTYPort::open(), instead use the cross-platform serialport::open() or serialport::open_with_settings().

Methods

impl TTYPort[src]

pub fn open(path: &Path, settings: &SerialPortSettings) -> Result<TTYPort>[src]

Opens a TTY device as a serial port.

path should be the path to a TTY device, e.g., /dev/ttyS0.

Ports are opened in exclusive mode by default. If this is undesireable behavior, use TTYPort::set_exclusive(false).

Errors

  • NoDevice if the device could not be opened. This could indicate that the device is already in use.
  • InvalidInput if path is not a valid device name.
  • Io for any other error while opening or initializing the device.

pub fn exclusive(&self) -> bool[src]

Returns the exclusivity of the port

If a port is exclusive, then trying to open the same device path again will fail.

pub fn set_exclusive(&mut self, exclusive: bool) -> Result<()>[src]

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.

pub fn pair() -> Result<(Self, Self)>[src]

Create a pair of pseudo serial terminals

Returns

Two connected TTYPort objects: (master, slave)

Errors

Attempting any IO or parameter settings on the slave tty after the master tty is closed will return errors.

On some platforms manipulating the master port will fail and only modifying the slave port is possible.

Examples

use serialport::posix::TTYPort;

let (master, slave) = TTYPort::pair().unwrap();

Trait Implementations

impl SerialPort for TTYPort[src]

fn settings(&self) -> SerialPortSettings[src]

Returns a struct with all port settings

fn baud_rate(&self) -> Result<u32>[src]

Returns the port's baud rate

On some platforms this will be the actual device baud rate, which may differ from the desired baud rate.

impl Drop for TTYPort[src]

impl Debug for TTYPort[src]

impl Write for TTYPort[src]

fn write_vectored(&mut self, bufs: &[IoSlice]) -> Result<usize, Error>1.36.0[src]

Like write, except that it writes from a slice of buffers. Read more

fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>1.0.0[src]

Attempts to write an entire buffer into this writer. Read more

fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>1.0.0[src]

Writes a formatted string into this writer, returning any error encountered. Read more

fn by_ref(&mut self) -> &mut Self1.0.0[src]

Creates a "by reference" adaptor for this instance of Write. Read more

impl Read for TTYPort[src]

fn read_vectored(&mut self, bufs: &mut [IoSliceMut]) -> Result<usize, Error>1.36.0[src]

Like read, except that it reads into a slice of buffers. Read more

unsafe fn initializer(&self) -> Initializer[src]

🔬 This is a nightly-only experimental API. (read_initializer)

Determines if this Reader can work with buffers of uninitialized memory. Read more

fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>1.0.0[src]

Read all bytes until EOF in this source, placing them into buf. Read more

fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>1.0.0[src]

Read all bytes until EOF in this source, appending them to buf. Read more

fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>1.6.0[src]

Read the exact number of bytes required to fill buf. Read more

fn by_ref(&mut self) -> &mut Self1.0.0[src]

Creates a "by reference" adaptor for this instance of Read. Read more

fn bytes(self) -> Bytes<Self>1.0.0[src]

Transforms this Read instance to an [Iterator] over its bytes. Read more

fn chain<R>(self, next: R) -> Chain<Self, R> where
    R: Read
1.0.0[src]

Creates an adaptor which will chain this stream with another. Read more

fn take(self, limit: u64) -> Take<Self>1.0.0[src]

Creates an adaptor which will read at most limit bytes from it. Read more

impl AsRawFd for TTYPort[src]

impl FromRawFd for TTYPort[src]

impl IntoRawFd for TTYPort[src]

Auto Trait Implementations

impl Send for TTYPort

impl Sync for TTYPort

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]