use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum GreenEnergyEfficient {
Appliances,
Construction,
Doors,
ExposureShade,
HVAC,
Incentives,
Insulation,
Lighting,
Roof,
Thermostat,
WaterHeater,
Windows,
OpenEnumeration(String),
}
impl crate::ResoEnumeration for GreenEnergyEfficient {
fn from_str(s: &str) -> GreenEnergyEfficient {
match s {
"Appliances" => GreenEnergyEfficient::Appliances,
"Construction" => GreenEnergyEfficient::Construction,
"Doors" => GreenEnergyEfficient::Doors,
"Exposure/Shade" => GreenEnergyEfficient::ExposureShade,
"HVAC" => GreenEnergyEfficient::HVAC,
"Incentives" => GreenEnergyEfficient::Incentives,
"Insulation" => GreenEnergyEfficient::Insulation,
"Lighting" => GreenEnergyEfficient::Lighting,
"Roof" => GreenEnergyEfficient::Roof,
"Thermostat" => GreenEnergyEfficient::Thermostat,
"Water Heater" => GreenEnergyEfficient::WaterHeater,
"Windows" => GreenEnergyEfficient::Windows,
_ => GreenEnergyEfficient::OpenEnumeration(s.into()),
}
}
fn from_string(s: String) -> GreenEnergyEfficient {
match s.as_ref() {
"Appliances" => GreenEnergyEfficient::Appliances,
"Construction" => GreenEnergyEfficient::Construction,
"Doors" => GreenEnergyEfficient::Doors,
"Exposure/Shade" => GreenEnergyEfficient::ExposureShade,
"HVAC" => GreenEnergyEfficient::HVAC,
"Incentives" => GreenEnergyEfficient::Incentives,
"Insulation" => GreenEnergyEfficient::Insulation,
"Lighting" => GreenEnergyEfficient::Lighting,
"Roof" => GreenEnergyEfficient::Roof,
"Thermostat" => GreenEnergyEfficient::Thermostat,
"Water Heater" => GreenEnergyEfficient::WaterHeater,
"Windows" => GreenEnergyEfficient::Windows,
_ => GreenEnergyEfficient::OpenEnumeration(s),
}
}
fn to_str(&self) -> &str {
match self {
GreenEnergyEfficient::Appliances => "Appliances",
GreenEnergyEfficient::Construction => "Construction",
GreenEnergyEfficient::Doors => "Doors",
GreenEnergyEfficient::ExposureShade => "Exposure/Shade",
GreenEnergyEfficient::HVAC => "HVAC",
GreenEnergyEfficient::Incentives => "Incentives",
GreenEnergyEfficient::Insulation => "Insulation",
GreenEnergyEfficient::Lighting => "Lighting",
GreenEnergyEfficient::Roof => "Roof",
GreenEnergyEfficient::Thermostat => "Thermostat",
GreenEnergyEfficient::WaterHeater => "Water Heater",
GreenEnergyEfficient::Windows => "Windows",
GreenEnergyEfficient::OpenEnumeration(ref s) => s,
}
}
fn into_string(self) -> String {
match self {
GreenEnergyEfficient::Appliances => "Appliances".into(),
GreenEnergyEfficient::Construction => "Construction".into(),
GreenEnergyEfficient::Doors => "Doors".into(),
GreenEnergyEfficient::ExposureShade => "Exposure/Shade".into(),
GreenEnergyEfficient::HVAC => "HVAC".into(),
GreenEnergyEfficient::Incentives => "Incentives".into(),
GreenEnergyEfficient::Insulation => "Insulation".into(),
GreenEnergyEfficient::Lighting => "Lighting".into(),
GreenEnergyEfficient::Roof => "Roof".into(),
GreenEnergyEfficient::Thermostat => "Thermostat".into(),
GreenEnergyEfficient::WaterHeater => "Water Heater".into(),
GreenEnergyEfficient::Windows => "Windows".into(),
GreenEnergyEfficient::OpenEnumeration(s) => s,
}
}
fn fallback_value(&self) -> Option<&str> {
match self {
GreenEnergyEfficient::OpenEnumeration(ref s) => Some(s),
_ => None,
}
}
}
impl From<String> for GreenEnergyEfficient {
fn from(s: String) -> GreenEnergyEfficient {
match s.as_ref() {
"Appliances" => GreenEnergyEfficient::Appliances,
"Construction" => GreenEnergyEfficient::Construction,
"Doors" => GreenEnergyEfficient::Doors,
"Exposure/Shade" => GreenEnergyEfficient::ExposureShade,
"HVAC" => GreenEnergyEfficient::HVAC,
"Incentives" => GreenEnergyEfficient::Incentives,
"Insulation" => GreenEnergyEfficient::Insulation,
"Lighting" => GreenEnergyEfficient::Lighting,
"Roof" => GreenEnergyEfficient::Roof,
"Thermostat" => GreenEnergyEfficient::Thermostat,
"Water Heater" => GreenEnergyEfficient::WaterHeater,
"Windows" => GreenEnergyEfficient::Windows,
_ => GreenEnergyEfficient::OpenEnumeration(s),
}
}
}
impl From<&str> for GreenEnergyEfficient {
fn from(s: &str) -> GreenEnergyEfficient {
match s {
"Appliances" => GreenEnergyEfficient::Appliances,
"Construction" => GreenEnergyEfficient::Construction,
"Doors" => GreenEnergyEfficient::Doors,
"Exposure/Shade" => GreenEnergyEfficient::ExposureShade,
"HVAC" => GreenEnergyEfficient::HVAC,
"Incentives" => GreenEnergyEfficient::Incentives,
"Insulation" => GreenEnergyEfficient::Insulation,
"Lighting" => GreenEnergyEfficient::Lighting,
"Roof" => GreenEnergyEfficient::Roof,
"Thermostat" => GreenEnergyEfficient::Thermostat,
"Water Heater" => GreenEnergyEfficient::WaterHeater,
"Windows" => GreenEnergyEfficient::Windows,
_ => GreenEnergyEfficient::OpenEnumeration(s.into()),
}
}
}
impl<'a> From<&'a GreenEnergyEfficient> for &'a str {
fn from(s: &'a GreenEnergyEfficient) -> &'a str {
match s {
GreenEnergyEfficient::Appliances => "Appliances",
GreenEnergyEfficient::Construction => "Construction",
GreenEnergyEfficient::Doors => "Doors",
GreenEnergyEfficient::ExposureShade => "Exposure/Shade",
GreenEnergyEfficient::HVAC => "HVAC",
GreenEnergyEfficient::Incentives => "Incentives",
GreenEnergyEfficient::Insulation => "Insulation",
GreenEnergyEfficient::Lighting => "Lighting",
GreenEnergyEfficient::Roof => "Roof",
GreenEnergyEfficient::Thermostat => "Thermostat",
GreenEnergyEfficient::WaterHeater => "Water Heater",
GreenEnergyEfficient::Windows => "Windows",
GreenEnergyEfficient::OpenEnumeration(s) => s,
}
}
}
impl Serialize for GreenEnergyEfficient {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(self.into())
}
}
impl<'de> Deserialize<'de> for GreenEnergyEfficient {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = String::deserialize(deserializer)?;
Ok(From::from(s))
}
}