rsiot/components_config/uart_general/
parity.rs

1//! Добавлять бит четности
2
3/// Добавлять бит четности
4#[allow(missing_docs)]
5#[derive(Clone, Debug, Default)]
6pub enum Parity {
7    #[default]
8    None,
9    Even,
10    Odd,
11}
12
13#[cfg(feature = "cmp_esp")]
14impl From<Parity> for esp_idf_svc::hal::uart::config::Parity {
15    fn from(value: Parity) -> Self {
16        match value {
17            Parity::None => Self::ParityNone,
18            Parity::Even => Self::ParityEven,
19            Parity::Odd => Self::ParityOdd,
20        }
21    }
22}
23
24impl From<Parity> for f64 {
25    fn from(value: Parity) -> Self {
26        match value {
27            Parity::None => 0.0,
28            Parity::Even | Parity::Odd => 1.0,
29        }
30    }
31}