use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum OtherEquipment {
AirPurifier,
CallListingAgent,
Compressor,
DCWellPump,
Dehumidifier,
FarmEquipment,
FuelTanks,
Generator,
HomeTheater,
Intercom,
IrrigationEquipment,
ListAvailable,
LivestockEquipment,
Negotiable,
None,
OrchardEquipment,
Other,
RotaryAntenna,
SatelliteDish,
TVAntenna,
VariesbyUnit,
OpenEnumeration(String),
}
impl crate::ResoEnumeration for OtherEquipment {
fn from_str(s: &str) -> OtherEquipment {
match s {
"Air Purifier" => OtherEquipment::AirPurifier,
"Call Listing Agent" => OtherEquipment::CallListingAgent,
"Compressor" => OtherEquipment::Compressor,
"DC Well Pump" => OtherEquipment::DCWellPump,
"Dehumidifier" => OtherEquipment::Dehumidifier,
"Farm Equipment" => OtherEquipment::FarmEquipment,
"Fuel Tank(s)" => OtherEquipment::FuelTanks,
"Generator" => OtherEquipment::Generator,
"Home Theater" => OtherEquipment::HomeTheater,
"Intercom" => OtherEquipment::Intercom,
"Irrigation Equipment" => OtherEquipment::IrrigationEquipment,
"List Available" => OtherEquipment::ListAvailable,
"Livestock Equipment" => OtherEquipment::LivestockEquipment,
"Negotiable" => OtherEquipment::Negotiable,
"None" => OtherEquipment::None,
"Orchard Equipment" => OtherEquipment::OrchardEquipment,
"Other" => OtherEquipment::Other,
"Rotary Antenna" => OtherEquipment::RotaryAntenna,
"Satellite Dish" => OtherEquipment::SatelliteDish,
"TV Antenna" => OtherEquipment::TVAntenna,
"Varies by Unit" => OtherEquipment::VariesbyUnit,
_ => OtherEquipment::OpenEnumeration(s.into()),
}
}
fn from_string(s: String) -> OtherEquipment {
match s.as_ref() {
"Air Purifier" => OtherEquipment::AirPurifier,
"Call Listing Agent" => OtherEquipment::CallListingAgent,
"Compressor" => OtherEquipment::Compressor,
"DC Well Pump" => OtherEquipment::DCWellPump,
"Dehumidifier" => OtherEquipment::Dehumidifier,
"Farm Equipment" => OtherEquipment::FarmEquipment,
"Fuel Tank(s)" => OtherEquipment::FuelTanks,
"Generator" => OtherEquipment::Generator,
"Home Theater" => OtherEquipment::HomeTheater,
"Intercom" => OtherEquipment::Intercom,
"Irrigation Equipment" => OtherEquipment::IrrigationEquipment,
"List Available" => OtherEquipment::ListAvailable,
"Livestock Equipment" => OtherEquipment::LivestockEquipment,
"Negotiable" => OtherEquipment::Negotiable,
"None" => OtherEquipment::None,
"Orchard Equipment" => OtherEquipment::OrchardEquipment,
"Other" => OtherEquipment::Other,
"Rotary Antenna" => OtherEquipment::RotaryAntenna,
"Satellite Dish" => OtherEquipment::SatelliteDish,
"TV Antenna" => OtherEquipment::TVAntenna,
"Varies by Unit" => OtherEquipment::VariesbyUnit,
_ => OtherEquipment::OpenEnumeration(s),
}
}
fn to_str(&self) -> &str {
match self {
OtherEquipment::AirPurifier => "Air Purifier",
OtherEquipment::CallListingAgent => "Call Listing Agent",
OtherEquipment::Compressor => "Compressor",
OtherEquipment::DCWellPump => "DC Well Pump",
OtherEquipment::Dehumidifier => "Dehumidifier",
OtherEquipment::FarmEquipment => "Farm Equipment",
OtherEquipment::FuelTanks => "Fuel Tank(s)",
OtherEquipment::Generator => "Generator",
OtherEquipment::HomeTheater => "Home Theater",
OtherEquipment::Intercom => "Intercom",
OtherEquipment::IrrigationEquipment => "Irrigation Equipment",
OtherEquipment::ListAvailable => "List Available",
OtherEquipment::LivestockEquipment => "Livestock Equipment",
OtherEquipment::Negotiable => "Negotiable",
OtherEquipment::None => "None",
OtherEquipment::OrchardEquipment => "Orchard Equipment",
OtherEquipment::Other => "Other",
OtherEquipment::RotaryAntenna => "Rotary Antenna",
OtherEquipment::SatelliteDish => "Satellite Dish",
OtherEquipment::TVAntenna => "TV Antenna",
OtherEquipment::VariesbyUnit => "Varies by Unit",
OtherEquipment::OpenEnumeration(ref s) => s,
}
}
fn into_string(self) -> String {
match self {
OtherEquipment::AirPurifier => "Air Purifier".into(),
OtherEquipment::CallListingAgent => "Call Listing Agent".into(),
OtherEquipment::Compressor => "Compressor".into(),
OtherEquipment::DCWellPump => "DC Well Pump".into(),
OtherEquipment::Dehumidifier => "Dehumidifier".into(),
OtherEquipment::FarmEquipment => "Farm Equipment".into(),
OtherEquipment::FuelTanks => "Fuel Tank(s)".into(),
OtherEquipment::Generator => "Generator".into(),
OtherEquipment::HomeTheater => "Home Theater".into(),
OtherEquipment::Intercom => "Intercom".into(),
OtherEquipment::IrrigationEquipment => "Irrigation Equipment".into(),
OtherEquipment::ListAvailable => "List Available".into(),
OtherEquipment::LivestockEquipment => "Livestock Equipment".into(),
OtherEquipment::Negotiable => "Negotiable".into(),
OtherEquipment::None => "None".into(),
OtherEquipment::OrchardEquipment => "Orchard Equipment".into(),
OtherEquipment::Other => "Other".into(),
OtherEquipment::RotaryAntenna => "Rotary Antenna".into(),
OtherEquipment::SatelliteDish => "Satellite Dish".into(),
OtherEquipment::TVAntenna => "TV Antenna".into(),
OtherEquipment::VariesbyUnit => "Varies by Unit".into(),
OtherEquipment::OpenEnumeration(s) => s,
}
}
fn fallback_value(&self) -> Option<&str> {
match self {
OtherEquipment::OpenEnumeration(ref s) => Some(s),
_ => None,
}
}
}
impl From<String> for OtherEquipment {
fn from(s: String) -> OtherEquipment {
match s.as_ref() {
"Air Purifier" => OtherEquipment::AirPurifier,
"Call Listing Agent" => OtherEquipment::CallListingAgent,
"Compressor" => OtherEquipment::Compressor,
"DC Well Pump" => OtherEquipment::DCWellPump,
"Dehumidifier" => OtherEquipment::Dehumidifier,
"Farm Equipment" => OtherEquipment::FarmEquipment,
"Fuel Tank(s)" => OtherEquipment::FuelTanks,
"Generator" => OtherEquipment::Generator,
"Home Theater" => OtherEquipment::HomeTheater,
"Intercom" => OtherEquipment::Intercom,
"Irrigation Equipment" => OtherEquipment::IrrigationEquipment,
"List Available" => OtherEquipment::ListAvailable,
"Livestock Equipment" => OtherEquipment::LivestockEquipment,
"Negotiable" => OtherEquipment::Negotiable,
"None" => OtherEquipment::None,
"Orchard Equipment" => OtherEquipment::OrchardEquipment,
"Other" => OtherEquipment::Other,
"Rotary Antenna" => OtherEquipment::RotaryAntenna,
"Satellite Dish" => OtherEquipment::SatelliteDish,
"TV Antenna" => OtherEquipment::TVAntenna,
"Varies by Unit" => OtherEquipment::VariesbyUnit,
_ => OtherEquipment::OpenEnumeration(s),
}
}
}
impl From<&str> for OtherEquipment {
fn from(s: &str) -> OtherEquipment {
match s {
"Air Purifier" => OtherEquipment::AirPurifier,
"Call Listing Agent" => OtherEquipment::CallListingAgent,
"Compressor" => OtherEquipment::Compressor,
"DC Well Pump" => OtherEquipment::DCWellPump,
"Dehumidifier" => OtherEquipment::Dehumidifier,
"Farm Equipment" => OtherEquipment::FarmEquipment,
"Fuel Tank(s)" => OtherEquipment::FuelTanks,
"Generator" => OtherEquipment::Generator,
"Home Theater" => OtherEquipment::HomeTheater,
"Intercom" => OtherEquipment::Intercom,
"Irrigation Equipment" => OtherEquipment::IrrigationEquipment,
"List Available" => OtherEquipment::ListAvailable,
"Livestock Equipment" => OtherEquipment::LivestockEquipment,
"Negotiable" => OtherEquipment::Negotiable,
"None" => OtherEquipment::None,
"Orchard Equipment" => OtherEquipment::OrchardEquipment,
"Other" => OtherEquipment::Other,
"Rotary Antenna" => OtherEquipment::RotaryAntenna,
"Satellite Dish" => OtherEquipment::SatelliteDish,
"TV Antenna" => OtherEquipment::TVAntenna,
"Varies by Unit" => OtherEquipment::VariesbyUnit,
_ => OtherEquipment::OpenEnumeration(s.into()),
}
}
}
impl<'a> From<&'a OtherEquipment> for &'a str {
fn from(s: &'a OtherEquipment) -> &'a str {
match s {
OtherEquipment::AirPurifier => "Air Purifier",
OtherEquipment::CallListingAgent => "Call Listing Agent",
OtherEquipment::Compressor => "Compressor",
OtherEquipment::DCWellPump => "DC Well Pump",
OtherEquipment::Dehumidifier => "Dehumidifier",
OtherEquipment::FarmEquipment => "Farm Equipment",
OtherEquipment::FuelTanks => "Fuel Tank(s)",
OtherEquipment::Generator => "Generator",
OtherEquipment::HomeTheater => "Home Theater",
OtherEquipment::Intercom => "Intercom",
OtherEquipment::IrrigationEquipment => "Irrigation Equipment",
OtherEquipment::ListAvailable => "List Available",
OtherEquipment::LivestockEquipment => "Livestock Equipment",
OtherEquipment::Negotiable => "Negotiable",
OtherEquipment::None => "None",
OtherEquipment::OrchardEquipment => "Orchard Equipment",
OtherEquipment::Other => "Other",
OtherEquipment::RotaryAntenna => "Rotary Antenna",
OtherEquipment::SatelliteDish => "Satellite Dish",
OtherEquipment::TVAntenna => "TV Antenna",
OtherEquipment::VariesbyUnit => "Varies by Unit",
OtherEquipment::OpenEnumeration(s) => s,
}
}
}
impl Serialize for OtherEquipment {
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 OtherEquipment {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = String::deserialize(deserializer)?;
Ok(From::from(s))
}
}