common/emgauwa-controller/src/driver.rs

20 lines
430 B
Rust

use serde::{Deserialize, Deserializer};
#[derive(Debug, Clone, Copy)]
pub enum Driver {
Gpio,
Piface,
}
impl<'de> Deserialize<'de> for Driver {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
match String::deserialize(deserializer)?.as_str() {
"gpio" => Ok(Driver::Gpio),
"piface" => Ok(Driver::Piface),
_ => Err(serde::de::Error::custom("invalid driver")),
}
}
}