Skip to main content

SerialPortStreamBuilder

Struct SerialPortStreamBuilder 

Source
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

Source

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"
Source

pub fn baud_rate(self, baud_rate: u32) -> Self

Sets the baud rate (bits per second).

Common values: 9600, 19200, 38400, 57600, 115200

Source

pub fn data_bits(self, data_bits: DataBits) -> Self

Sets the number of data bits per character.

Default: DataBits::Eight

Source

pub fn flow_control(self, flow_control: FlowControl) -> Self

Sets the flow control mode.

Default: FlowControl::None

Source

pub fn parity(self, parity: Parity) -> Self

Sets the parity checking mode.

Default: Parity::None

Source

pub fn stop_bits(self, stop_bits: StopBits) -> Self

Sets the number of stop bits.

Default: StopBits::One

Source

pub fn dtr_on_open(self, state: bool) -> Self

Sets the DTR (Data Terminal Ready) signal state applied when opening the port.

Default: false

Source

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

Source

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

Source§

fn clone(&self) -> SerialPortStreamBuilder

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SerialPortStreamBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for SerialPortStreamBuilder

Source§

impl PartialEq for SerialPortStreamBuilder

Source§

fn eq(&self, other: &SerialPortStreamBuilder) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for SerialPortStreamBuilder

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.