hass_rs/types/
panels.rs

1use std::collections::HashMap;
2use std::fmt;
3
4use serde::{Deserialize, Serialize};
5
6pub type HassPanels = HashMap<String, HassPanel>;
7
8#[derive(Debug, Serialize, Deserialize, PartialEq)]
9pub struct HassPanel {
10    pub component_name: String,
11    pub config: Option<HassPanelConfig>,
12    pub icon: Option<String>,
13    pub require_admin: bool,
14    pub title: Option<String>,
15    pub url_path: String,
16}
17
18#[derive(Debug, Serialize, Deserialize, PartialEq)]
19pub struct HassPanelConfig {
20    #[serde(rename = "_panel_custom")]
21    pub custom_panel: Option<HassCustomPanelConfig>,
22    pub mode: Option<String>,
23    pub title: Option<String>,
24}
25
26#[derive(Debug, Serialize, Deserialize, PartialEq)]
27pub struct HassCustomPanelConfig {
28    pub embed_iframe: bool,
29    pub module_url: Option<String>,
30    pub js_url: Option<String>,
31    pub name: String,
32    pub trust_external: bool,
33}
34
35impl fmt::Display for HassPanel {
36    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
37        write!(f, "HassPanel {{\n")?;
38        write!(f, "  component_name: {},\n", self.component_name)?;
39        write!(f, "  config: {:?},\n", self.config)?;
40        write!(f, "  icon: {:?},\n", self.icon)?;
41        write!(f, "  require_admin: {},\n", self.require_admin)?;
42        write!(f, "  title: {:?},\n", self.title)?;
43        write!(f, "  url_path: {},\n", self.url_path)?;
44        write!(f, "}}")?;
45        Ok(())
46    }
47}
48
49impl fmt::Display for HassPanelConfig {
50    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
51        write!(f, "HassPanelConfig {{\n")?;
52        write!(f, "  custom_panel: {:?},\n", self.custom_panel)?;
53        write!(f, "  mode: {:?},\n", self.mode)?;
54        write!(f, "  title: {:?},\n", self.title)?;
55        write!(f, "}}")?;
56        Ok(())
57    }
58}
59
60impl fmt::Display for HassCustomPanelConfig {
61    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
62        write!(f, "HassCustomPanelConfig {{\n")?;
63        write!(f, "  embed_iframe: {},\n", self.embed_iframe)?;
64        write!(f, "  module_url: {:?},\n", self.module_url)?;
65        write!(f, "  js_url: {:?},\n", self.js_url)?;
66        write!(f, "  name: {},\n", self.name)?;
67        write!(f, "  trust_external: {},\n", self.trust_external)?;
68        write!(f, "}}")?;
69        Ok(())
70    }
71}