pub struct SerialPortStreamBuilder { /* private fields */ }Expand description
Builder for serial port path, line settings, and one-shot open options.
Created with new(), configured with chained methods, then finalized with
open().
§Example
use serialport_stream::new;
use serialport_stream::{ClearBuffer, DataBits, FlowControl, Parity, StopBits};
let stream = new("/dev/ttyUSB0", 115200)
.data_bits(DataBits::Eight)
.parity(Parity::None)
.stop_bits(StopBits::One)
.flow_control(FlowControl::None)
.dtr_on_open(true)
.clear(ClearBuffer::All)
.open()?;Implementations§
Source§impl SerialPortStreamBuilder
impl SerialPortStreamBuilder
Sourcepub fn path<'a>(self, path: impl Into<Cow<'a, str>>) -> Self
pub fn path<'a>(self, path: impl Into<Cow<'a, str>>) -> Self
Sets the path to the serial port device.
§Examples
- Unix:
"/dev/ttyUSB0","/dev/ttyACM0" - Windows:
"COM3","COM10"
Sourcepub fn baud_rate(self, baud_rate: u32) -> Self
pub fn baud_rate(self, baud_rate: u32) -> Self
Sets the baud rate (bits per second).
Common values: 9600, 19200, 38400, 57600, 115200
Sourcepub fn data_bits(self, data_bits: DataBits) -> Self
pub fn data_bits(self, data_bits: DataBits) -> Self
Sets the number of data bits per character.
Default: DataBits::Eight
Sourcepub fn flow_control(self, flow_control: FlowControl) -> Self
pub fn flow_control(self, flow_control: FlowControl) -> Self
Sets the flow control mode.
Default: FlowControl::None
Sourcepub fn parity(self, parity: Parity) -> Self
pub fn parity(self, parity: Parity) -> Self
Sets the parity checking mode.
Default: Parity::None
Sourcepub fn stop_bits(self, stop_bits: StopBits) -> Self
pub fn stop_bits(self, stop_bits: StopBits) -> Self
Sets the number of stop bits.
Default: StopBits::One
Sourcepub fn dtr_on_open(self, state: bool) -> Self
pub fn dtr_on_open(self, state: bool) -> Self
Sets the DTR (Data Terminal Ready) signal state applied when opening the port.
Default: false
Sourcepub fn clear(self, buffer: ClearBuffer) -> Self
pub fn clear(self, buffer: ClearBuffer) -> Self
Clears RX and/or TX driver buffers when the port is opened, before async I/O starts.
See ClearBuffer (Input, Output, or All).
Sourcepub fn open(self) -> Result<SerialPortStream>
pub fn open(self) -> Result<SerialPortStream>
Opens the serial port and returns a SerialPortStream.
Applies line settings, dtr_on_open, and optional
clear before any background read/write threads are started.
Trait Implementations§
Source§impl Clone for SerialPortStreamBuilder
impl Clone for SerialPortStreamBuilder
Source§fn clone(&self) -> SerialPortStreamBuilder
fn clone(&self) -> SerialPortStreamBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SerialPortStreamBuilder
impl Debug for SerialPortStreamBuilder
impl Eq for SerialPortStreamBuilder
Source§impl PartialEq for SerialPortStreamBuilder
impl PartialEq for SerialPortStreamBuilder
Source§fn eq(&self, other: &SerialPortStreamBuilder) -> bool
fn eq(&self, other: &SerialPortStreamBuilder) -> bool
self and other values to be equal, and is used by ==.