chore: support into trait for subscription plan and recurring interval
This commit is contained in:
parent
8b5a803d44
commit
9c3529f0ca
|
|
@ -3,8 +3,8 @@ use serde::{Deserialize, Serialize};
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
|
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
pub enum RecurringInterval {
|
pub enum RecurringInterval {
|
||||||
Month,
|
Month = 0,
|
||||||
Year,
|
Year = 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RecurringInterval {
|
impl RecurringInterval {
|
||||||
|
|
@ -28,6 +28,15 @@ impl TryFrom<i16> for RecurringInterval {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Into<i16> for RecurringInterval {
|
||||||
|
fn into(self) -> i16 {
|
||||||
|
match self {
|
||||||
|
RecurringInterval::Month => 0,
|
||||||
|
RecurringInterval::Year => 1,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
#[repr(i16)]
|
#[repr(i16)]
|
||||||
|
|
@ -55,6 +64,18 @@ impl TryFrom<i16> for SubscriptionPlan {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Into<i16> for SubscriptionPlan {
|
||||||
|
fn into(self) -> i16 {
|
||||||
|
match self {
|
||||||
|
SubscriptionPlan::Free => 0,
|
||||||
|
SubscriptionPlan::Pro => 1,
|
||||||
|
SubscriptionPlan::Team => 2,
|
||||||
|
SubscriptionPlan::AiMax => 3,
|
||||||
|
SubscriptionPlan::AiLocal => 4,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl AsRef<str> for SubscriptionPlan {
|
impl AsRef<str> for SubscriptionPlan {
|
||||||
fn as_ref(&self) -> &str {
|
fn as_ref(&self) -> &str {
|
||||||
match self {
|
match self {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue