rsiot/components_config/uart_general/
data_bits.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//! Кол-во бит данных

/// Кол-во бит данных
#[allow(missing_docs)]
#[derive(Clone, Debug, Default)]
pub enum DataBits {
    _5,
    _6,
    _7,
    #[default]
    _8,
}

impl From<DataBits> for f64 {
    fn from(value: DataBits) -> Self {
        match value {
            DataBits::_5 => 5.0,
            DataBits::_6 => 6.0,
            DataBits::_7 => 7.0,
            DataBits::_8 => 8.0,
        }
    }
}

#[cfg(feature = "cmp_esp")]
impl From<DataBits> for esp_idf_svc::hal::uart::config::DataBits {
    fn from(value: DataBits) -> Self {
        match value {
            DataBits::_5 => Self::DataBits5,
            DataBits::_6 => Self::DataBits6,
            DataBits::_7 => Self::DataBits7,
            DataBits::_8 => Self::DataBits8,
        }
    }
}