1use super::schema::{allowed_states, gpio_state};
2use std::collections::HashMap;
3
4#[derive(Debug, Serialize, Deserialize, Queryable, Insertable)]
5#[table_name = "gpio_state"]
6pub struct Gpio {
7 pub gpio_id: i32, pub in_use: i32, pub gpio_mode: Option<String>, pub gpio_level: Option<String>, pub last_change: Option<String>, }
13
14#[derive(Debug, Serialize, Deserialize, Queryable, Insertable)]
15#[table_name = "allowed_states"]
16pub struct AllowedStates {
17 pub state_id: i32,
18 pub state_type: String, pub input: i32,
21 pub output: i32,
22 pub high: i32,
23 pub low: i32,
24}
25
26impl AllowedStates {
27 pub fn to_hashmap(&self) -> HashMap<&'static str, bool> {
28 let mut hashed: HashMap<&'static str, bool> = HashMap::new();
29 hashed.insert("input", self.input == 1);
30 hashed.insert("output", self.output == 1);
31 hashed.insert("high", self.high == 1);
32 hashed.insert("low", self.low == 1);
33 hashed
34 }
35}