use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
#[non_exhaustive]
pub enum Vendor {
Tasmota,
Shelly,
}
impl Vendor {
pub fn as_str(&self) -> &'static str {
match self {
Vendor::Tasmota => "tasmota",
Vendor::Shelly => "shelly",
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct DeviceCredentials {
pub user: String,
pub password: String,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct DeviceTarget {
pub host: String,
pub credentials: Option<DeviceCredentials>,
}
impl DeviceTarget {
pub fn new(host: impl Into<String>) -> Self {
DeviceTarget {
host: host.into(),
credentials: None,
}
}
pub fn with_credentials(mut self, credentials: Option<DeviceCredentials>) -> Self {
self.credentials = credentials;
self
}
}