1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use serde;
use serde::{Serialize, Deserialize};
use crate::errors::WledJsonApiError;
use crate::structures::state::State;
use crate::structures::info::Info;

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StateInfo {
    pub state: State,
    pub info: Info,
}

impl TryFrom<&str> for StateInfo{
    type Error = WledJsonApiError;
    fn try_from(str_in: &str) -> Result<StateInfo, WledJsonApiError> {
        serde_json::from_str(str_in).map_err(|e| {WledJsonApiError::SerdeError(e)})
    }
}