use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum RoomType {
Basement,
Bathroom,
Bathroom1,
Bathroom2,
Bathroom3,
Bathroom4,
Bathroom5,
Bedroom,
Bedroom1,
Bedroom2,
Bedroom3,
Bedroom4,
Bedroom5,
BonusRoom,
Den,
DiningRoom,
ExerciseRoom,
FamilyRoom,
GameRoom,
GreatRoom,
Gym,
Kitchen,
Laundry,
Library,
LivingRoom,
Loft,
MasterBathroom,
MasterBedroom,
MediaRoom,
Office,
Sauna,
UtilityRoom,
Workshop,
OpenEnumeration(String),
}
impl crate::ResoEnumeration for RoomType {
fn from_str(s: &str) -> RoomType {
match s {
"Basement" => RoomType::Basement,
"Bathroom" => RoomType::Bathroom,
"Bathroom 1" => RoomType::Bathroom1,
"Bathroom 2" => RoomType::Bathroom2,
"Bathroom 3" => RoomType::Bathroom3,
"Bathroom 4" => RoomType::Bathroom4,
"Bathroom 5" => RoomType::Bathroom5,
"Bedroom" => RoomType::Bedroom,
"Bedroom 1" => RoomType::Bedroom1,
"Bedroom 2" => RoomType::Bedroom2,
"Bedroom 3" => RoomType::Bedroom3,
"Bedroom 4" => RoomType::Bedroom4,
"Bedroom 5" => RoomType::Bedroom5,
"Bonus Room" => RoomType::BonusRoom,
"Den" => RoomType::Den,
"Dining Room" => RoomType::DiningRoom,
"Exercise Room" => RoomType::ExerciseRoom,
"Family Room" => RoomType::FamilyRoom,
"Game Room" => RoomType::GameRoom,
"Great Room" => RoomType::GreatRoom,
"Gym" => RoomType::Gym,
"Kitchen" => RoomType::Kitchen,
"Laundry" => RoomType::Laundry,
"Library" => RoomType::Library,
"Living Room" => RoomType::LivingRoom,
"Loft" => RoomType::Loft,
"Master Bathroom" => RoomType::MasterBathroom,
"Master Bedroom" => RoomType::MasterBedroom,
"Media Room" => RoomType::MediaRoom,
"Office" => RoomType::Office,
"Sauna" => RoomType::Sauna,
"Utility Room" => RoomType::UtilityRoom,
"Workshop" => RoomType::Workshop,
_ => RoomType::OpenEnumeration(s.into()),
}
}
fn from_string(s: String) -> RoomType {
match s.as_ref() {
"Basement" => RoomType::Basement,
"Bathroom" => RoomType::Bathroom,
"Bathroom 1" => RoomType::Bathroom1,
"Bathroom 2" => RoomType::Bathroom2,
"Bathroom 3" => RoomType::Bathroom3,
"Bathroom 4" => RoomType::Bathroom4,
"Bathroom 5" => RoomType::Bathroom5,
"Bedroom" => RoomType::Bedroom,
"Bedroom 1" => RoomType::Bedroom1,
"Bedroom 2" => RoomType::Bedroom2,
"Bedroom 3" => RoomType::Bedroom3,
"Bedroom 4" => RoomType::Bedroom4,
"Bedroom 5" => RoomType::Bedroom5,
"Bonus Room" => RoomType::BonusRoom,
"Den" => RoomType::Den,
"Dining Room" => RoomType::DiningRoom,
"Exercise Room" => RoomType::ExerciseRoom,
"Family Room" => RoomType::FamilyRoom,
"Game Room" => RoomType::GameRoom,
"Great Room" => RoomType::GreatRoom,
"Gym" => RoomType::Gym,
"Kitchen" => RoomType::Kitchen,
"Laundry" => RoomType::Laundry,
"Library" => RoomType::Library,
"Living Room" => RoomType::LivingRoom,
"Loft" => RoomType::Loft,
"Master Bathroom" => RoomType::MasterBathroom,
"Master Bedroom" => RoomType::MasterBedroom,
"Media Room" => RoomType::MediaRoom,
"Office" => RoomType::Office,
"Sauna" => RoomType::Sauna,
"Utility Room" => RoomType::UtilityRoom,
"Workshop" => RoomType::Workshop,
_ => RoomType::OpenEnumeration(s),
}
}
fn to_str(&self) -> &str {
match self {
RoomType::Basement => "Basement",
RoomType::Bathroom => "Bathroom",
RoomType::Bathroom1 => "Bathroom 1",
RoomType::Bathroom2 => "Bathroom 2",
RoomType::Bathroom3 => "Bathroom 3",
RoomType::Bathroom4 => "Bathroom 4",
RoomType::Bathroom5 => "Bathroom 5",
RoomType::Bedroom => "Bedroom",
RoomType::Bedroom1 => "Bedroom 1",
RoomType::Bedroom2 => "Bedroom 2",
RoomType::Bedroom3 => "Bedroom 3",
RoomType::Bedroom4 => "Bedroom 4",
RoomType::Bedroom5 => "Bedroom 5",
RoomType::BonusRoom => "Bonus Room",
RoomType::Den => "Den",
RoomType::DiningRoom => "Dining Room",
RoomType::ExerciseRoom => "Exercise Room",
RoomType::FamilyRoom => "Family Room",
RoomType::GameRoom => "Game Room",
RoomType::GreatRoom => "Great Room",
RoomType::Gym => "Gym",
RoomType::Kitchen => "Kitchen",
RoomType::Laundry => "Laundry",
RoomType::Library => "Library",
RoomType::LivingRoom => "Living Room",
RoomType::Loft => "Loft",
RoomType::MasterBathroom => "Master Bathroom",
RoomType::MasterBedroom => "Master Bedroom",
RoomType::MediaRoom => "Media Room",
RoomType::Office => "Office",
RoomType::Sauna => "Sauna",
RoomType::UtilityRoom => "Utility Room",
RoomType::Workshop => "Workshop",
RoomType::OpenEnumeration(ref s) => s,
}
}
fn into_string(self) -> String {
match self {
RoomType::Basement => "Basement".into(),
RoomType::Bathroom => "Bathroom".into(),
RoomType::Bathroom1 => "Bathroom 1".into(),
RoomType::Bathroom2 => "Bathroom 2".into(),
RoomType::Bathroom3 => "Bathroom 3".into(),
RoomType::Bathroom4 => "Bathroom 4".into(),
RoomType::Bathroom5 => "Bathroom 5".into(),
RoomType::Bedroom => "Bedroom".into(),
RoomType::Bedroom1 => "Bedroom 1".into(),
RoomType::Bedroom2 => "Bedroom 2".into(),
RoomType::Bedroom3 => "Bedroom 3".into(),
RoomType::Bedroom4 => "Bedroom 4".into(),
RoomType::Bedroom5 => "Bedroom 5".into(),
RoomType::BonusRoom => "Bonus Room".into(),
RoomType::Den => "Den".into(),
RoomType::DiningRoom => "Dining Room".into(),
RoomType::ExerciseRoom => "Exercise Room".into(),
RoomType::FamilyRoom => "Family Room".into(),
RoomType::GameRoom => "Game Room".into(),
RoomType::GreatRoom => "Great Room".into(),
RoomType::Gym => "Gym".into(),
RoomType::Kitchen => "Kitchen".into(),
RoomType::Laundry => "Laundry".into(),
RoomType::Library => "Library".into(),
RoomType::LivingRoom => "Living Room".into(),
RoomType::Loft => "Loft".into(),
RoomType::MasterBathroom => "Master Bathroom".into(),
RoomType::MasterBedroom => "Master Bedroom".into(),
RoomType::MediaRoom => "Media Room".into(),
RoomType::Office => "Office".into(),
RoomType::Sauna => "Sauna".into(),
RoomType::UtilityRoom => "Utility Room".into(),
RoomType::Workshop => "Workshop".into(),
RoomType::OpenEnumeration(s) => s,
}
}
fn fallback_value(&self) -> Option<&str> {
match self {
RoomType::OpenEnumeration(ref s) => Some(s),
_ => None,
}
}
}
impl From<String> for RoomType {
fn from(s: String) -> RoomType {
match s.as_ref() {
"Basement" => RoomType::Basement,
"Bathroom" => RoomType::Bathroom,
"Bathroom 1" => RoomType::Bathroom1,
"Bathroom 2" => RoomType::Bathroom2,
"Bathroom 3" => RoomType::Bathroom3,
"Bathroom 4" => RoomType::Bathroom4,
"Bathroom 5" => RoomType::Bathroom5,
"Bedroom" => RoomType::Bedroom,
"Bedroom 1" => RoomType::Bedroom1,
"Bedroom 2" => RoomType::Bedroom2,
"Bedroom 3" => RoomType::Bedroom3,
"Bedroom 4" => RoomType::Bedroom4,
"Bedroom 5" => RoomType::Bedroom5,
"Bonus Room" => RoomType::BonusRoom,
"Den" => RoomType::Den,
"Dining Room" => RoomType::DiningRoom,
"Exercise Room" => RoomType::ExerciseRoom,
"Family Room" => RoomType::FamilyRoom,
"Game Room" => RoomType::GameRoom,
"Great Room" => RoomType::GreatRoom,
"Gym" => RoomType::Gym,
"Kitchen" => RoomType::Kitchen,
"Laundry" => RoomType::Laundry,
"Library" => RoomType::Library,
"Living Room" => RoomType::LivingRoom,
"Loft" => RoomType::Loft,
"Master Bathroom" => RoomType::MasterBathroom,
"Master Bedroom" => RoomType::MasterBedroom,
"Media Room" => RoomType::MediaRoom,
"Office" => RoomType::Office,
"Sauna" => RoomType::Sauna,
"Utility Room" => RoomType::UtilityRoom,
"Workshop" => RoomType::Workshop,
_ => RoomType::OpenEnumeration(s),
}
}
}
impl From<&str> for RoomType {
fn from(s: &str) -> RoomType {
match s {
"Basement" => RoomType::Basement,
"Bathroom" => RoomType::Bathroom,
"Bathroom 1" => RoomType::Bathroom1,
"Bathroom 2" => RoomType::Bathroom2,
"Bathroom 3" => RoomType::Bathroom3,
"Bathroom 4" => RoomType::Bathroom4,
"Bathroom 5" => RoomType::Bathroom5,
"Bedroom" => RoomType::Bedroom,
"Bedroom 1" => RoomType::Bedroom1,
"Bedroom 2" => RoomType::Bedroom2,
"Bedroom 3" => RoomType::Bedroom3,
"Bedroom 4" => RoomType::Bedroom4,
"Bedroom 5" => RoomType::Bedroom5,
"Bonus Room" => RoomType::BonusRoom,
"Den" => RoomType::Den,
"Dining Room" => RoomType::DiningRoom,
"Exercise Room" => RoomType::ExerciseRoom,
"Family Room" => RoomType::FamilyRoom,
"Game Room" => RoomType::GameRoom,
"Great Room" => RoomType::GreatRoom,
"Gym" => RoomType::Gym,
"Kitchen" => RoomType::Kitchen,
"Laundry" => RoomType::Laundry,
"Library" => RoomType::Library,
"Living Room" => RoomType::LivingRoom,
"Loft" => RoomType::Loft,
"Master Bathroom" => RoomType::MasterBathroom,
"Master Bedroom" => RoomType::MasterBedroom,
"Media Room" => RoomType::MediaRoom,
"Office" => RoomType::Office,
"Sauna" => RoomType::Sauna,
"Utility Room" => RoomType::UtilityRoom,
"Workshop" => RoomType::Workshop,
_ => RoomType::OpenEnumeration(s.into()),
}
}
}
impl<'a> From<&'a RoomType> for &'a str {
fn from(s: &'a RoomType) -> &'a str {
match s {
RoomType::Basement => "Basement",
RoomType::Bathroom => "Bathroom",
RoomType::Bathroom1 => "Bathroom 1",
RoomType::Bathroom2 => "Bathroom 2",
RoomType::Bathroom3 => "Bathroom 3",
RoomType::Bathroom4 => "Bathroom 4",
RoomType::Bathroom5 => "Bathroom 5",
RoomType::Bedroom => "Bedroom",
RoomType::Bedroom1 => "Bedroom 1",
RoomType::Bedroom2 => "Bedroom 2",
RoomType::Bedroom3 => "Bedroom 3",
RoomType::Bedroom4 => "Bedroom 4",
RoomType::Bedroom5 => "Bedroom 5",
RoomType::BonusRoom => "Bonus Room",
RoomType::Den => "Den",
RoomType::DiningRoom => "Dining Room",
RoomType::ExerciseRoom => "Exercise Room",
RoomType::FamilyRoom => "Family Room",
RoomType::GameRoom => "Game Room",
RoomType::GreatRoom => "Great Room",
RoomType::Gym => "Gym",
RoomType::Kitchen => "Kitchen",
RoomType::Laundry => "Laundry",
RoomType::Library => "Library",
RoomType::LivingRoom => "Living Room",
RoomType::Loft => "Loft",
RoomType::MasterBathroom => "Master Bathroom",
RoomType::MasterBedroom => "Master Bedroom",
RoomType::MediaRoom => "Media Room",
RoomType::Office => "Office",
RoomType::Sauna => "Sauna",
RoomType::UtilityRoom => "Utility Room",
RoomType::Workshop => "Workshop",
RoomType::OpenEnumeration(s) => s,
}
}
}
impl Serialize for RoomType {
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 RoomType {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = String::deserialize(deserializer)?;
Ok(From::from(s))
}
}