use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum EventType {
ClicktoPrimaryHostedSite,
ClickedonEmailAddress,
ClickedonPhoneNumber,
Comments,
DetailedView,
Discard,
DrivingDirections,
ExitDetailedView,
Favorited,
Maybe,
NonDetailedView,
ObjectModified,
PhotoGallery,
Printed,
PropertyVideos,
Search,
Share,
SubmissionofLeadForm,
VirtualTour,
OpenEnumeration(String),
}
impl crate::ResoEnumeration for EventType {
fn from_str(s: &str) -> EventType {
match s {
"Click to Primary Hosted Site" => EventType::ClicktoPrimaryHostedSite,
"Clicked on Email Address" => EventType::ClickedonEmailAddress,
"Clicked on Phone Number" => EventType::ClickedonPhoneNumber,
"Comments" => EventType::Comments,
"Detailed View" => EventType::DetailedView,
"Discard" => EventType::Discard,
"Driving Directions" => EventType::DrivingDirections,
"Exit Detailed View" => EventType::ExitDetailedView,
"Favorited" => EventType::Favorited,
"Maybe" => EventType::Maybe,
"Non-Detailed View" => EventType::NonDetailedView,
"Object Modified" => EventType::ObjectModified,
"Photo Gallery" => EventType::PhotoGallery,
"Printed" => EventType::Printed,
"Property Videos" => EventType::PropertyVideos,
"Search" => EventType::Search,
"Share" => EventType::Share,
"Submission of Lead Form" => EventType::SubmissionofLeadForm,
"Virtual Tour" => EventType::VirtualTour,
_ => EventType::OpenEnumeration(s.into()),
}
}
fn from_string(s: String) -> EventType {
match s.as_ref() {
"Click to Primary Hosted Site" => EventType::ClicktoPrimaryHostedSite,
"Clicked on Email Address" => EventType::ClickedonEmailAddress,
"Clicked on Phone Number" => EventType::ClickedonPhoneNumber,
"Comments" => EventType::Comments,
"Detailed View" => EventType::DetailedView,
"Discard" => EventType::Discard,
"Driving Directions" => EventType::DrivingDirections,
"Exit Detailed View" => EventType::ExitDetailedView,
"Favorited" => EventType::Favorited,
"Maybe" => EventType::Maybe,
"Non-Detailed View" => EventType::NonDetailedView,
"Object Modified" => EventType::ObjectModified,
"Photo Gallery" => EventType::PhotoGallery,
"Printed" => EventType::Printed,
"Property Videos" => EventType::PropertyVideos,
"Search" => EventType::Search,
"Share" => EventType::Share,
"Submission of Lead Form" => EventType::SubmissionofLeadForm,
"Virtual Tour" => EventType::VirtualTour,
_ => EventType::OpenEnumeration(s),
}
}
fn to_str(&self) -> &str {
match self {
EventType::ClicktoPrimaryHostedSite => "Click to Primary Hosted Site",
EventType::ClickedonEmailAddress => "Clicked on Email Address",
EventType::ClickedonPhoneNumber => "Clicked on Phone Number",
EventType::Comments => "Comments",
EventType::DetailedView => "Detailed View",
EventType::Discard => "Discard",
EventType::DrivingDirections => "Driving Directions",
EventType::ExitDetailedView => "Exit Detailed View",
EventType::Favorited => "Favorited",
EventType::Maybe => "Maybe",
EventType::NonDetailedView => "Non-Detailed View",
EventType::ObjectModified => "Object Modified",
EventType::PhotoGallery => "Photo Gallery",
EventType::Printed => "Printed",
EventType::PropertyVideos => "Property Videos",
EventType::Search => "Search",
EventType::Share => "Share",
EventType::SubmissionofLeadForm => "Submission of Lead Form",
EventType::VirtualTour => "Virtual Tour",
EventType::OpenEnumeration(ref s) => s,
}
}
fn into_string(self) -> String {
match self {
EventType::ClicktoPrimaryHostedSite => "Click to Primary Hosted Site".into(),
EventType::ClickedonEmailAddress => "Clicked on Email Address".into(),
EventType::ClickedonPhoneNumber => "Clicked on Phone Number".into(),
EventType::Comments => "Comments".into(),
EventType::DetailedView => "Detailed View".into(),
EventType::Discard => "Discard".into(),
EventType::DrivingDirections => "Driving Directions".into(),
EventType::ExitDetailedView => "Exit Detailed View".into(),
EventType::Favorited => "Favorited".into(),
EventType::Maybe => "Maybe".into(),
EventType::NonDetailedView => "Non-Detailed View".into(),
EventType::ObjectModified => "Object Modified".into(),
EventType::PhotoGallery => "Photo Gallery".into(),
EventType::Printed => "Printed".into(),
EventType::PropertyVideos => "Property Videos".into(),
EventType::Search => "Search".into(),
EventType::Share => "Share".into(),
EventType::SubmissionofLeadForm => "Submission of Lead Form".into(),
EventType::VirtualTour => "Virtual Tour".into(),
EventType::OpenEnumeration(s) => s,
}
}
fn fallback_value(&self) -> Option<&str> {
match self {
EventType::OpenEnumeration(ref s) => Some(s),
_ => None,
}
}
}
impl From<String> for EventType {
fn from(s: String) -> EventType {
match s.as_ref() {
"Click to Primary Hosted Site" => EventType::ClicktoPrimaryHostedSite,
"Clicked on Email Address" => EventType::ClickedonEmailAddress,
"Clicked on Phone Number" => EventType::ClickedonPhoneNumber,
"Comments" => EventType::Comments,
"Detailed View" => EventType::DetailedView,
"Discard" => EventType::Discard,
"Driving Directions" => EventType::DrivingDirections,
"Exit Detailed View" => EventType::ExitDetailedView,
"Favorited" => EventType::Favorited,
"Maybe" => EventType::Maybe,
"Non-Detailed View" => EventType::NonDetailedView,
"Object Modified" => EventType::ObjectModified,
"Photo Gallery" => EventType::PhotoGallery,
"Printed" => EventType::Printed,
"Property Videos" => EventType::PropertyVideos,
"Search" => EventType::Search,
"Share" => EventType::Share,
"Submission of Lead Form" => EventType::SubmissionofLeadForm,
"Virtual Tour" => EventType::VirtualTour,
_ => EventType::OpenEnumeration(s),
}
}
}
impl From<&str> for EventType {
fn from(s: &str) -> EventType {
match s {
"Click to Primary Hosted Site" => EventType::ClicktoPrimaryHostedSite,
"Clicked on Email Address" => EventType::ClickedonEmailAddress,
"Clicked on Phone Number" => EventType::ClickedonPhoneNumber,
"Comments" => EventType::Comments,
"Detailed View" => EventType::DetailedView,
"Discard" => EventType::Discard,
"Driving Directions" => EventType::DrivingDirections,
"Exit Detailed View" => EventType::ExitDetailedView,
"Favorited" => EventType::Favorited,
"Maybe" => EventType::Maybe,
"Non-Detailed View" => EventType::NonDetailedView,
"Object Modified" => EventType::ObjectModified,
"Photo Gallery" => EventType::PhotoGallery,
"Printed" => EventType::Printed,
"Property Videos" => EventType::PropertyVideos,
"Search" => EventType::Search,
"Share" => EventType::Share,
"Submission of Lead Form" => EventType::SubmissionofLeadForm,
"Virtual Tour" => EventType::VirtualTour,
_ => EventType::OpenEnumeration(s.into()),
}
}
}
impl<'a> From<&'a EventType> for &'a str {
fn from(s: &'a EventType) -> &'a str {
match s {
EventType::ClicktoPrimaryHostedSite => "Click to Primary Hosted Site",
EventType::ClickedonEmailAddress => "Clicked on Email Address",
EventType::ClickedonPhoneNumber => "Clicked on Phone Number",
EventType::Comments => "Comments",
EventType::DetailedView => "Detailed View",
EventType::Discard => "Discard",
EventType::DrivingDirections => "Driving Directions",
EventType::ExitDetailedView => "Exit Detailed View",
EventType::Favorited => "Favorited",
EventType::Maybe => "Maybe",
EventType::NonDetailedView => "Non-Detailed View",
EventType::ObjectModified => "Object Modified",
EventType::PhotoGallery => "Photo Gallery",
EventType::Printed => "Printed",
EventType::PropertyVideos => "Property Videos",
EventType::Search => "Search",
EventType::Share => "Share",
EventType::SubmissionofLeadForm => "Submission of Lead Form",
EventType::VirtualTour => "Virtual Tour",
EventType::OpenEnumeration(s) => s,
}
}
}
impl Serialize for EventType {
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 EventType {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = String::deserialize(deserializer)?;
Ok(From::from(s))
}
}