use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum PropertySubType {
Agriculture,
Apartment,
BoatSlip,
Business,
Cabin,
Condominium,
DeededParking,
Duplex,
Farm,
HotelMotel,
Industrial,
ManufacturedHome,
ManufacturedOnLand,
MixedUse,
MobileHome,
MultiFamily,
Office,
OwnYourOwn,
Quadruplex,
Ranch,
Retail,
SingleFamilyResidence,
StockCooperative,
Timeshare,
Townhouse,
Triplex,
UnimprovedLand,
Warehouse,
OpenEnumeration(String),
}
impl crate::ResoEnumeration for PropertySubType {
fn from_str(s: &str) -> PropertySubType {
match s {
"Agriculture" => PropertySubType::Agriculture,
"Apartment" => PropertySubType::Apartment,
"Boat Slip" => PropertySubType::BoatSlip,
"Business" => PropertySubType::Business,
"Cabin" => PropertySubType::Cabin,
"Condominium" => PropertySubType::Condominium,
"Deeded Parking" => PropertySubType::DeededParking,
"Duplex" => PropertySubType::Duplex,
"Farm" => PropertySubType::Farm,
"Hotel/Motel" => PropertySubType::HotelMotel,
"Industrial" => PropertySubType::Industrial,
"Manufactured Home" => PropertySubType::ManufacturedHome,
"Manufactured On Land" => PropertySubType::ManufacturedOnLand,
"Mixed Use" => PropertySubType::MixedUse,
"Mobile Home" => PropertySubType::MobileHome,
"Multi Family" => PropertySubType::MultiFamily,
"Office" => PropertySubType::Office,
"Own Your Own" => PropertySubType::OwnYourOwn,
"Quadruplex" => PropertySubType::Quadruplex,
"Ranch" => PropertySubType::Ranch,
"Retail" => PropertySubType::Retail,
"Single Family Residence" => PropertySubType::SingleFamilyResidence,
"Stock Cooperative" => PropertySubType::StockCooperative,
"Timeshare" => PropertySubType::Timeshare,
"Townhouse" => PropertySubType::Townhouse,
"Triplex" => PropertySubType::Triplex,
"Unimproved Land" => PropertySubType::UnimprovedLand,
"Warehouse" => PropertySubType::Warehouse,
_ => PropertySubType::OpenEnumeration(s.into()),
}
}
fn from_string(s: String) -> PropertySubType {
match s.as_ref() {
"Agriculture" => PropertySubType::Agriculture,
"Apartment" => PropertySubType::Apartment,
"Boat Slip" => PropertySubType::BoatSlip,
"Business" => PropertySubType::Business,
"Cabin" => PropertySubType::Cabin,
"Condominium" => PropertySubType::Condominium,
"Deeded Parking" => PropertySubType::DeededParking,
"Duplex" => PropertySubType::Duplex,
"Farm" => PropertySubType::Farm,
"Hotel/Motel" => PropertySubType::HotelMotel,
"Industrial" => PropertySubType::Industrial,
"Manufactured Home" => PropertySubType::ManufacturedHome,
"Manufactured On Land" => PropertySubType::ManufacturedOnLand,
"Mixed Use" => PropertySubType::MixedUse,
"Mobile Home" => PropertySubType::MobileHome,
"Multi Family" => PropertySubType::MultiFamily,
"Office" => PropertySubType::Office,
"Own Your Own" => PropertySubType::OwnYourOwn,
"Quadruplex" => PropertySubType::Quadruplex,
"Ranch" => PropertySubType::Ranch,
"Retail" => PropertySubType::Retail,
"Single Family Residence" => PropertySubType::SingleFamilyResidence,
"Stock Cooperative" => PropertySubType::StockCooperative,
"Timeshare" => PropertySubType::Timeshare,
"Townhouse" => PropertySubType::Townhouse,
"Triplex" => PropertySubType::Triplex,
"Unimproved Land" => PropertySubType::UnimprovedLand,
"Warehouse" => PropertySubType::Warehouse,
_ => PropertySubType::OpenEnumeration(s),
}
}
fn to_str(&self) -> &str {
match self {
PropertySubType::Agriculture => "Agriculture",
PropertySubType::Apartment => "Apartment",
PropertySubType::BoatSlip => "Boat Slip",
PropertySubType::Business => "Business",
PropertySubType::Cabin => "Cabin",
PropertySubType::Condominium => "Condominium",
PropertySubType::DeededParking => "Deeded Parking",
PropertySubType::Duplex => "Duplex",
PropertySubType::Farm => "Farm",
PropertySubType::HotelMotel => "Hotel/Motel",
PropertySubType::Industrial => "Industrial",
PropertySubType::ManufacturedHome => "Manufactured Home",
PropertySubType::ManufacturedOnLand => "Manufactured On Land",
PropertySubType::MixedUse => "Mixed Use",
PropertySubType::MobileHome => "Mobile Home",
PropertySubType::MultiFamily => "Multi Family",
PropertySubType::Office => "Office",
PropertySubType::OwnYourOwn => "Own Your Own",
PropertySubType::Quadruplex => "Quadruplex",
PropertySubType::Ranch => "Ranch",
PropertySubType::Retail => "Retail",
PropertySubType::SingleFamilyResidence => "Single Family Residence",
PropertySubType::StockCooperative => "Stock Cooperative",
PropertySubType::Timeshare => "Timeshare",
PropertySubType::Townhouse => "Townhouse",
PropertySubType::Triplex => "Triplex",
PropertySubType::UnimprovedLand => "Unimproved Land",
PropertySubType::Warehouse => "Warehouse",
PropertySubType::OpenEnumeration(ref s) => s,
}
}
fn into_string(self) -> String {
match self {
PropertySubType::Agriculture => "Agriculture".into(),
PropertySubType::Apartment => "Apartment".into(),
PropertySubType::BoatSlip => "Boat Slip".into(),
PropertySubType::Business => "Business".into(),
PropertySubType::Cabin => "Cabin".into(),
PropertySubType::Condominium => "Condominium".into(),
PropertySubType::DeededParking => "Deeded Parking".into(),
PropertySubType::Duplex => "Duplex".into(),
PropertySubType::Farm => "Farm".into(),
PropertySubType::HotelMotel => "Hotel/Motel".into(),
PropertySubType::Industrial => "Industrial".into(),
PropertySubType::ManufacturedHome => "Manufactured Home".into(),
PropertySubType::ManufacturedOnLand => "Manufactured On Land".into(),
PropertySubType::MixedUse => "Mixed Use".into(),
PropertySubType::MobileHome => "Mobile Home".into(),
PropertySubType::MultiFamily => "Multi Family".into(),
PropertySubType::Office => "Office".into(),
PropertySubType::OwnYourOwn => "Own Your Own".into(),
PropertySubType::Quadruplex => "Quadruplex".into(),
PropertySubType::Ranch => "Ranch".into(),
PropertySubType::Retail => "Retail".into(),
PropertySubType::SingleFamilyResidence => "Single Family Residence".into(),
PropertySubType::StockCooperative => "Stock Cooperative".into(),
PropertySubType::Timeshare => "Timeshare".into(),
PropertySubType::Townhouse => "Townhouse".into(),
PropertySubType::Triplex => "Triplex".into(),
PropertySubType::UnimprovedLand => "Unimproved Land".into(),
PropertySubType::Warehouse => "Warehouse".into(),
PropertySubType::OpenEnumeration(s) => s,
}
}
fn fallback_value(&self) -> Option<&str> {
match self {
PropertySubType::OpenEnumeration(ref s) => Some(s),
_ => None,
}
}
}
impl From<String> for PropertySubType {
fn from(s: String) -> PropertySubType {
match s.as_ref() {
"Agriculture" => PropertySubType::Agriculture,
"Apartment" => PropertySubType::Apartment,
"Boat Slip" => PropertySubType::BoatSlip,
"Business" => PropertySubType::Business,
"Cabin" => PropertySubType::Cabin,
"Condominium" => PropertySubType::Condominium,
"Deeded Parking" => PropertySubType::DeededParking,
"Duplex" => PropertySubType::Duplex,
"Farm" => PropertySubType::Farm,
"Hotel/Motel" => PropertySubType::HotelMotel,
"Industrial" => PropertySubType::Industrial,
"Manufactured Home" => PropertySubType::ManufacturedHome,
"Manufactured On Land" => PropertySubType::ManufacturedOnLand,
"Mixed Use" => PropertySubType::MixedUse,
"Mobile Home" => PropertySubType::MobileHome,
"Multi Family" => PropertySubType::MultiFamily,
"Office" => PropertySubType::Office,
"Own Your Own" => PropertySubType::OwnYourOwn,
"Quadruplex" => PropertySubType::Quadruplex,
"Ranch" => PropertySubType::Ranch,
"Retail" => PropertySubType::Retail,
"Single Family Residence" => PropertySubType::SingleFamilyResidence,
"Stock Cooperative" => PropertySubType::StockCooperative,
"Timeshare" => PropertySubType::Timeshare,
"Townhouse" => PropertySubType::Townhouse,
"Triplex" => PropertySubType::Triplex,
"Unimproved Land" => PropertySubType::UnimprovedLand,
"Warehouse" => PropertySubType::Warehouse,
_ => PropertySubType::OpenEnumeration(s),
}
}
}
impl From<&str> for PropertySubType {
fn from(s: &str) -> PropertySubType {
match s {
"Agriculture" => PropertySubType::Agriculture,
"Apartment" => PropertySubType::Apartment,
"Boat Slip" => PropertySubType::BoatSlip,
"Business" => PropertySubType::Business,
"Cabin" => PropertySubType::Cabin,
"Condominium" => PropertySubType::Condominium,
"Deeded Parking" => PropertySubType::DeededParking,
"Duplex" => PropertySubType::Duplex,
"Farm" => PropertySubType::Farm,
"Hotel/Motel" => PropertySubType::HotelMotel,
"Industrial" => PropertySubType::Industrial,
"Manufactured Home" => PropertySubType::ManufacturedHome,
"Manufactured On Land" => PropertySubType::ManufacturedOnLand,
"Mixed Use" => PropertySubType::MixedUse,
"Mobile Home" => PropertySubType::MobileHome,
"Multi Family" => PropertySubType::MultiFamily,
"Office" => PropertySubType::Office,
"Own Your Own" => PropertySubType::OwnYourOwn,
"Quadruplex" => PropertySubType::Quadruplex,
"Ranch" => PropertySubType::Ranch,
"Retail" => PropertySubType::Retail,
"Single Family Residence" => PropertySubType::SingleFamilyResidence,
"Stock Cooperative" => PropertySubType::StockCooperative,
"Timeshare" => PropertySubType::Timeshare,
"Townhouse" => PropertySubType::Townhouse,
"Triplex" => PropertySubType::Triplex,
"Unimproved Land" => PropertySubType::UnimprovedLand,
"Warehouse" => PropertySubType::Warehouse,
_ => PropertySubType::OpenEnumeration(s.into()),
}
}
}
impl<'a> From<&'a PropertySubType> for &'a str {
fn from(s: &'a PropertySubType) -> &'a str {
match s {
PropertySubType::Agriculture => "Agriculture",
PropertySubType::Apartment => "Apartment",
PropertySubType::BoatSlip => "Boat Slip",
PropertySubType::Business => "Business",
PropertySubType::Cabin => "Cabin",
PropertySubType::Condominium => "Condominium",
PropertySubType::DeededParking => "Deeded Parking",
PropertySubType::Duplex => "Duplex",
PropertySubType::Farm => "Farm",
PropertySubType::HotelMotel => "Hotel/Motel",
PropertySubType::Industrial => "Industrial",
PropertySubType::ManufacturedHome => "Manufactured Home",
PropertySubType::ManufacturedOnLand => "Manufactured On Land",
PropertySubType::MixedUse => "Mixed Use",
PropertySubType::MobileHome => "Mobile Home",
PropertySubType::MultiFamily => "Multi Family",
PropertySubType::Office => "Office",
PropertySubType::OwnYourOwn => "Own Your Own",
PropertySubType::Quadruplex => "Quadruplex",
PropertySubType::Ranch => "Ranch",
PropertySubType::Retail => "Retail",
PropertySubType::SingleFamilyResidence => "Single Family Residence",
PropertySubType::StockCooperative => "Stock Cooperative",
PropertySubType::Timeshare => "Timeshare",
PropertySubType::Townhouse => "Townhouse",
PropertySubType::Triplex => "Triplex",
PropertySubType::UnimprovedLand => "Unimproved Land",
PropertySubType::Warehouse => "Warehouse",
PropertySubType::OpenEnumeration(s) => s,
}
}
}
impl Serialize for PropertySubType {
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 PropertySubType {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = String::deserialize(deserializer)?;
Ok(From::from(s))
}
}