serial_core

Enum BaudRate

Source
pub enum BaudRate {
    Baud110,
    Baud300,
    Baud600,
    Baud1200,
    Baud2400,
    Baud4800,
    Baud9600,
    Baud19200,
    Baud38400,
    Baud57600,
    Baud115200,
    BaudOther(usize),
}
Expand description

Serial port baud rates.

§Portability

The BaudRate variants with numeric suffixes, e.g., Baud9600, indicate standard baud rates that are widely-supported on many systems. While non-standard baud rates can be set with BaudOther, their behavior is system-dependent. Some systems may not support arbitrary baud rates. Using the standard baud rates is more likely to result in portable applications.

Variants§

§

Baud110

110 baud.

§

Baud300

300 baud.

§

Baud600

600 baud.

§

Baud1200

1200 baud.

§

Baud2400

2400 baud.

§

Baud4800

4800 baud.

§

Baud9600

9600 baud.

§

Baud19200

19,200 baud.

§

Baud38400

38,400 baud.

§

Baud57600

57,600 baud.

§

Baud115200

115,200 baud.

§

BaudOther(usize)

Non-standard baud rates.

BaudOther can be used to set non-standard baud rates by setting its member to be the desired baud rate.

serial_core::BaudOther(4_000_000); // 4,000,000 baud

Non-standard baud rates may not be supported on all systems.

Implementations§

Source§

impl BaudRate

Source

pub fn from_speed(speed: usize) -> BaudRate

Creates a BaudRate for a particular speed.

This function can be used to select a BaudRate variant from an integer containing the desired baud rate.

§Example
assert_eq!(BaudRate::Baud9600, BaudRate::from_speed(9600));
assert_eq!(BaudRate::Baud115200, BaudRate::from_speed(115200));
assert_eq!(BaudRate::BaudOther(4000000), BaudRate::from_speed(4000000));
Source

pub fn speed(&self) -> usize

Returns the baud rate as an integer.

§Example
assert_eq!(9600, BaudRate::Baud9600.speed());
assert_eq!(115200, BaudRate::Baud115200.speed());
assert_eq!(4000000, BaudRate::BaudOther(4000000).speed());

Trait Implementations§

Source§

impl Clone for BaudRate

Source§

fn clone(&self) -> BaudRate

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for BaudRate

Source§

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

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

impl PartialEq for BaudRate

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 Copy for BaudRate

Source§

impl Eq for BaudRate

Source§

impl StructuralPartialEq for BaudRate

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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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.