18 lines
No EOL
476 B
Rust
18 lines
No EOL
476 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")),
|
|
}
|
|
|
|
}
|
|
} |