common/emgauwa-controller/src/driver.rs

18 lines
476 B
Rust
Raw Normal View History

2023-11-24 23:39:44 +00:00
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")),
}
}
}