Struct serial_io::Serial[][src]

pub struct Serial { /* fields omitted */ }
Expand description

*nix serial port using termios

Implementations

Open a non-blocking serial port from the provided builder.

Example

use serial_io::{build, Serial, TTYPort};

let builder = build(tty_path, 9600);
let serial = Serial::from_builder(&builder).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 serial_io::Serial;

let (master, slave) = Serial::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.

Returns the exclusivity of the port

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

Trait Implementations

Extracts the raw file descriptor. Read more

Formats the value using the given formatter. Read more

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

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

Determines if this Reader has an efficient read_vectored implementation. Read more

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

Determines if this Reader 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

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

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

Creates an adaptor which will read at most limit bytes from it. 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

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

Determines if this Reader has an efficient read_vectored implementation. Read more

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

Determines if this Reader 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

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

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

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

Return the name associated with the serial port, if known.

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.

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 carefull 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.

Errors

This function returns an error if the serial port couldn’t be cloned.

Start transmitting a break

Stop transmitting a break

Register self with the given Registry instance. Read more

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

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

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

Determines if this Writer has an efficient write_vectored implementation. Read more

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

🔬 This is a nightly-only experimental API. (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

Creates a “by reference” adaptor for this instance of Write. 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

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

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

Determines if this Writer has an efficient write_vectored implementation. Read more

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

🔬 This is a nightly-only experimental API. (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

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.