#![allow(
clippy::too_many_arguments,
clippy::large_enum_variant,
clippy::doc_markdown,
)]
pub type AccountId = String;
#[derive(Debug)]
pub enum AccountType {
Basic,
Pro,
Business,
}
impl<'de> ::serde::de::Deserialize<'de> for AccountType {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = AccountType;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a AccountType structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
match tag {
"basic" => {
crate::eat_json_fields(&mut map)?;
Ok(AccountType::Basic)
}
"pro" => {
crate::eat_json_fields(&mut map)?;
Ok(AccountType::Pro)
}
"business" => {
crate::eat_json_fields(&mut map)?;
Ok(AccountType::Business)
}
_ => Err(de::Error::unknown_variant(tag, VARIANTS))
}
}
}
const VARIANTS: &[&str] = &["basic",
"pro",
"business"];
deserializer.deserialize_struct("AccountType", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for AccountType {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
AccountType::Basic => {
let mut s = serializer.serialize_struct("AccountType", 1)?;
s.serialize_field(".tag", "basic")?;
s.end()
}
AccountType::Pro => {
let mut s = serializer.serialize_struct("AccountType", 1)?;
s.serialize_field(".tag", "pro")?;
s.end()
}
AccountType::Business => {
let mut s = serializer.serialize_struct("AccountType", 1)?;
s.serialize_field(".tag", "business")?;
s.end()
}
}
}
}