use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum DevelopmentStatus {
Completed,
FinishedLots,
Other,
Proposed,
RawLand,
RoughGrade,
SeeRemarks,
SitePlanApproved,
SitePlanFiled,
UnderConstruction,
OpenEnumeration(String),
}
impl crate::ResoEnumeration for DevelopmentStatus {
fn from_str(s: &str) -> DevelopmentStatus {
match s {
"Completed" => DevelopmentStatus::Completed,
"Finished Lot(s)" => DevelopmentStatus::FinishedLots,
"Other" => DevelopmentStatus::Other,
"Proposed" => DevelopmentStatus::Proposed,
"Raw Land" => DevelopmentStatus::RawLand,
"Rough Grade" => DevelopmentStatus::RoughGrade,
"See Remarks" => DevelopmentStatus::SeeRemarks,
"Site Plan Approved" => DevelopmentStatus::SitePlanApproved,
"Site Plan Filed" => DevelopmentStatus::SitePlanFiled,
"Under Construction" => DevelopmentStatus::UnderConstruction,
_ => DevelopmentStatus::OpenEnumeration(s.into()),
}
}
fn from_string(s: String) -> DevelopmentStatus {
match s.as_ref() {
"Completed" => DevelopmentStatus::Completed,
"Finished Lot(s)" => DevelopmentStatus::FinishedLots,
"Other" => DevelopmentStatus::Other,
"Proposed" => DevelopmentStatus::Proposed,
"Raw Land" => DevelopmentStatus::RawLand,
"Rough Grade" => DevelopmentStatus::RoughGrade,
"See Remarks" => DevelopmentStatus::SeeRemarks,
"Site Plan Approved" => DevelopmentStatus::SitePlanApproved,
"Site Plan Filed" => DevelopmentStatus::SitePlanFiled,
"Under Construction" => DevelopmentStatus::UnderConstruction,
_ => DevelopmentStatus::OpenEnumeration(s),
}
}
fn to_str(&self) -> &str {
match self {
DevelopmentStatus::Completed => "Completed",
DevelopmentStatus::FinishedLots => "Finished Lot(s)",
DevelopmentStatus::Other => "Other",
DevelopmentStatus::Proposed => "Proposed",
DevelopmentStatus::RawLand => "Raw Land",
DevelopmentStatus::RoughGrade => "Rough Grade",
DevelopmentStatus::SeeRemarks => "See Remarks",
DevelopmentStatus::SitePlanApproved => "Site Plan Approved",
DevelopmentStatus::SitePlanFiled => "Site Plan Filed",
DevelopmentStatus::UnderConstruction => "Under Construction",
DevelopmentStatus::OpenEnumeration(ref s) => s,
}
}
fn into_string(self) -> String {
match self {
DevelopmentStatus::Completed => "Completed".into(),
DevelopmentStatus::FinishedLots => "Finished Lot(s)".into(),
DevelopmentStatus::Other => "Other".into(),
DevelopmentStatus::Proposed => "Proposed".into(),
DevelopmentStatus::RawLand => "Raw Land".into(),
DevelopmentStatus::RoughGrade => "Rough Grade".into(),
DevelopmentStatus::SeeRemarks => "See Remarks".into(),
DevelopmentStatus::SitePlanApproved => "Site Plan Approved".into(),
DevelopmentStatus::SitePlanFiled => "Site Plan Filed".into(),
DevelopmentStatus::UnderConstruction => "Under Construction".into(),
DevelopmentStatus::OpenEnumeration(s) => s,
}
}
fn fallback_value(&self) -> Option<&str> {
match self {
DevelopmentStatus::OpenEnumeration(ref s) => Some(s),
_ => None,
}
}
}
impl From<String> for DevelopmentStatus {
fn from(s: String) -> DevelopmentStatus {
match s.as_ref() {
"Completed" => DevelopmentStatus::Completed,
"Finished Lot(s)" => DevelopmentStatus::FinishedLots,
"Other" => DevelopmentStatus::Other,
"Proposed" => DevelopmentStatus::Proposed,
"Raw Land" => DevelopmentStatus::RawLand,
"Rough Grade" => DevelopmentStatus::RoughGrade,
"See Remarks" => DevelopmentStatus::SeeRemarks,
"Site Plan Approved" => DevelopmentStatus::SitePlanApproved,
"Site Plan Filed" => DevelopmentStatus::SitePlanFiled,
"Under Construction" => DevelopmentStatus::UnderConstruction,
_ => DevelopmentStatus::OpenEnumeration(s),
}
}
}
impl From<&str> for DevelopmentStatus {
fn from(s: &str) -> DevelopmentStatus {
match s {
"Completed" => DevelopmentStatus::Completed,
"Finished Lot(s)" => DevelopmentStatus::FinishedLots,
"Other" => DevelopmentStatus::Other,
"Proposed" => DevelopmentStatus::Proposed,
"Raw Land" => DevelopmentStatus::RawLand,
"Rough Grade" => DevelopmentStatus::RoughGrade,
"See Remarks" => DevelopmentStatus::SeeRemarks,
"Site Plan Approved" => DevelopmentStatus::SitePlanApproved,
"Site Plan Filed" => DevelopmentStatus::SitePlanFiled,
"Under Construction" => DevelopmentStatus::UnderConstruction,
_ => DevelopmentStatus::OpenEnumeration(s.into()),
}
}
}
impl<'a> From<&'a DevelopmentStatus> for &'a str {
fn from(s: &'a DevelopmentStatus) -> &'a str {
match s {
DevelopmentStatus::Completed => "Completed",
DevelopmentStatus::FinishedLots => "Finished Lot(s)",
DevelopmentStatus::Other => "Other",
DevelopmentStatus::Proposed => "Proposed",
DevelopmentStatus::RawLand => "Raw Land",
DevelopmentStatus::RoughGrade => "Rough Grade",
DevelopmentStatus::SeeRemarks => "See Remarks",
DevelopmentStatus::SitePlanApproved => "Site Plan Approved",
DevelopmentStatus::SitePlanFiled => "Site Plan Filed",
DevelopmentStatus::UnderConstruction => "Under Construction",
DevelopmentStatus::OpenEnumeration(s) => s,
}
}
}
impl Serialize for DevelopmentStatus {
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 DevelopmentStatus {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = String::deserialize(deserializer)?;
Ok(From::from(s))
}
}