#[repr(u16)]pub enum Baudrate {
BR1200 = 0,
BR2400 = 1,
BR4800 = 2,
BR9600 = 3,
BR19200 = 4,
BR38400 = 5,
BR57600 = 6,
BR115200 = 7,
}Expand description
Variants§
Implementations§
Source§impl Baudrate
impl Baudrate
Sourcepub fn from_id(id: u16) -> Option<Baudrate>
pub fn from_id(id: u16) -> Option<Baudrate>
Attempts to create a Baudrate from its internal ID.
This is used when a baudrate needs to be reconstructed from a stored or transmitted ID.
§Args
id: The internal identifier corresponding to aBaudrate.
§Returns
Some(..) if the ID matches a known baudrate, otherwise None.
§Examples
use modbus_rtu::common::Baudrate;
assert_eq!(Baudrate::from_id(3), Some(Baudrate::BR9600));
assert_eq!(Baudrate::from_id(99), None);Sourcepub fn to_id(&self) -> u16
pub fn to_id(&self) -> u16
Converts the Baudrate variant into its internal ID representation.
This ID can be stored or transmitted and later converted back using Baudrate::from_id.
§Returns
The internal u16 ID associated with the baudrate.
§Examples
use modbus_rtu::common::Baudrate;
assert_eq!(Baudrate::BR9600.to_id(), 3);Sourcepub fn packet_end_us(&self) -> u64
pub fn packet_end_us(&self) -> u64
Calculates the packet end timeout in microseconds based on the baudrate.
In Modbus RTU communication, this value defines the idle time required to consider a packet as ended. (3.5 char time)
§Returns
The idle time (in microseconds) required to delimit the end of a Modbus RTU packet at this baudrate.
§Examples
use modbus_rtu::common::Baudrate;
let baud = Baudrate::BR9600;
let packet_end_us: u64 = baud.packet_end_us();Trait Implementations§
Source§impl Ord for Baudrate
impl Ord for Baudrate
Source§impl PartialOrd for Baudrate
impl PartialOrd for Baudrate
impl Copy for Baudrate
impl Eq for Baudrate
impl StructuralPartialEq for Baudrate
Auto Trait Implementations§
impl Freeze for Baudrate
impl RefUnwindSafe for Baudrate
impl Send for Baudrate
impl Sync for Baudrate
impl Unpin for Baudrate
impl UnwindSafe for Baudrate
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