pub struct OpenSerialOptions { /* private fields */ }Available on crate feature
binary only.Expand description
Options for configuring and opening a serial port.
§Example
let mut port = OpenSerialOptions::new()
.timeout(Some(Duration::from_millis(50)))
.open("/dev/ttyUSB0")?;Implementations§
Source§impl OpenSerialOptions
impl OpenSerialOptions
Sourcepub const DEFAULT_BAUD_RATE: u32 = 9_600
pub const DEFAULT_BAUD_RATE: u32 = 9_600
The default baud rate for the Binary protocol: 9,600.
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a blank set of options ready for configuration.
The default baud rate and read timeout are 9,600 and 5 seconds, respectively.
Equivalent to default.
Sourcepub fn timeout(&mut self, duration: Option<Duration>) -> &mut Self
pub fn timeout(&mut self, duration: Option<Duration>) -> &mut Self
Set a custom read timeout.
If duration is None, reads will block indefinitely.
Sourcepub fn open<'a>(&self, path: &str) -> Result<Port<'a, Serial>, BinaryError>
pub fn open<'a>(&self, path: &str) -> Result<Port<'a, Serial>, BinaryError>
Open the port at the specified path with the custom options.
Sourcepub fn open_dyn<'a>(
&self,
path: &str,
) -> Result<Port<'a, Box<dyn Backend + Send>>, BinaryError>
pub fn open_dyn<'a>( &self, path: &str, ) -> Result<Port<'a, Box<dyn Backend + Send>>, BinaryError>
Open the port at the specified path with the custom options.
The type of the underlying backend is erased via dynamic dispatch,
which does have runtime overhead. open
should generally be used instead, except when the type of the underlying
backend may not be known at compile time.
Trait Implementations§
Source§impl Debug for OpenSerialOptions
impl Debug for OpenSerialOptions
Auto Trait Implementations§
impl Freeze for OpenSerialOptions
impl RefUnwindSafe for OpenSerialOptions
impl Send for OpenSerialOptions
impl Sync for OpenSerialOptions
impl Unpin for OpenSerialOptions
impl UnsafeUnpin for OpenSerialOptions
impl UnwindSafe for OpenSerialOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more