use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Deserialize, Serialize, Hash, PartialEq, Eq)]
#[serde(from = "i64", into = "i64")]
pub enum LifetimeDollarsPurchased {
Undeclared,
ZeroDollars,
OneCentToFortyNineDollarsAndNinetyNineCents,
FiftyDollarsToNinetyNineDollarsAndNinetyNineCents,
OneHundredDollarsToFourHundredNinetyNineDollarsAndNinetyNineCents,
FiveHundredDollarsToNineHundredNinetyNineDollarsAndNinetyNineCents,
OneThousandDollarsToOneThousandNineHundredNinetyNineDollarsAndNinetyNineCents,
TwoThousandDollarsOrGreater,
NotSupported(i64),
}
impl From<i64> for LifetimeDollarsPurchased {
fn from(value: i64) -> Self {
match value {
0 => LifetimeDollarsPurchased::Undeclared,
1 => LifetimeDollarsPurchased::ZeroDollars,
2 => LifetimeDollarsPurchased::OneCentToFortyNineDollarsAndNinetyNineCents,
3 => LifetimeDollarsPurchased::FiftyDollarsToNinetyNineDollarsAndNinetyNineCents,
4 => LifetimeDollarsPurchased::OneHundredDollarsToFourHundredNinetyNineDollarsAndNinetyNineCents,
5 => LifetimeDollarsPurchased::FiveHundredDollarsToNineHundredNinetyNineDollarsAndNinetyNineCents,
6 => {
LifetimeDollarsPurchased::OneThousandDollarsToOneThousandNineHundredNinetyNineDollarsAndNinetyNineCents
}
7 => LifetimeDollarsPurchased::TwoThousandDollarsOrGreater,
other => LifetimeDollarsPurchased::NotSupported(other),
}
}
}
impl From<LifetimeDollarsPurchased> for i64 {
fn from(value: LifetimeDollarsPurchased) -> Self {
match value {
LifetimeDollarsPurchased::Undeclared => 0,
LifetimeDollarsPurchased::ZeroDollars => 1,
LifetimeDollarsPurchased::OneCentToFortyNineDollarsAndNinetyNineCents => 2,
LifetimeDollarsPurchased::FiftyDollarsToNinetyNineDollarsAndNinetyNineCents => 3,
LifetimeDollarsPurchased::OneHundredDollarsToFourHundredNinetyNineDollarsAndNinetyNineCents => 4,
LifetimeDollarsPurchased::FiveHundredDollarsToNineHundredNinetyNineDollarsAndNinetyNineCents => 5,
LifetimeDollarsPurchased::OneThousandDollarsToOneThousandNineHundredNinetyNineDollarsAndNinetyNineCents => {
6
}
LifetimeDollarsPurchased::TwoThousandDollarsOrGreater => 7,
LifetimeDollarsPurchased::NotSupported(other) => other,
}
}
}