Skip to main content

rsiot/components_config/uart_general/
data_bits.rs

1//! Кол-во бит данных
2
3// ANCHOR: DataBits
4/// Кол-во бит данных
5#[allow(missing_docs)]
6#[derive(Clone, Copy, Debug, Default)]
7pub enum DataBits {
8    _5,
9    _6,
10    _7,
11    #[default]
12    _8,
13}
14// ANCHOR: DataBits
15
16impl From<DataBits> for f64 {
17    fn from(value: DataBits) -> Self {
18        match value {
19            DataBits::_5 => 5.0,
20            DataBits::_6 => 6.0,
21            DataBits::_7 => 7.0,
22            DataBits::_8 => 8.0,
23        }
24    }
25}
26
27#[cfg(feature = "cmp_esp")]
28impl From<DataBits> for esp_idf_svc::hal::uart::config::DataBits {
29    fn from(value: DataBits) -> Self {
30        match value {
31            DataBits::_5 => Self::DataBits5,
32            DataBits::_6 => Self::DataBits6,
33            DataBits::_7 => Self::DataBits7,
34            DataBits::_8 => Self::DataBits8,
35        }
36    }
37}