stripe_misc/
tax_product_registrations_resource_country_options_simplified.rs1#[derive(Copy, Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct TaxProductRegistrationsResourceCountryOptionsSimplified {
5 #[cfg_attr(any(feature = "deserialize", feature = "serialize"), serde(rename = "type"))]
7 pub type_: TaxProductRegistrationsResourceCountryOptionsSimplifiedType,
8}
9#[doc(hidden)]
10pub struct TaxProductRegistrationsResourceCountryOptionsSimplifiedBuilder {
11 type_: Option<TaxProductRegistrationsResourceCountryOptionsSimplifiedType>,
12}
13
14#[allow(
15 unused_variables,
16 irrefutable_let_patterns,
17 clippy::let_unit_value,
18 clippy::match_single_binding,
19 clippy::single_match
20)]
21const _: () = {
22 use miniserde::de::{Map, Visitor};
23 use miniserde::json::Value;
24 use miniserde::{Deserialize, Result, make_place};
25 use stripe_types::miniserde_helpers::FromValueOpt;
26 use stripe_types::{MapBuilder, ObjectDeser};
27
28 make_place!(Place);
29
30 impl Deserialize for TaxProductRegistrationsResourceCountryOptionsSimplified {
31 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
32 Place::new(out)
33 }
34 }
35
36 struct Builder<'a> {
37 out: &'a mut Option<TaxProductRegistrationsResourceCountryOptionsSimplified>,
38 builder: TaxProductRegistrationsResourceCountryOptionsSimplifiedBuilder,
39 }
40
41 impl Visitor for Place<TaxProductRegistrationsResourceCountryOptionsSimplified> {
42 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
43 Ok(Box::new(Builder {
44 out: &mut self.out,
45 builder:
46 TaxProductRegistrationsResourceCountryOptionsSimplifiedBuilder::deser_default(),
47 }))
48 }
49 }
50
51 impl MapBuilder for TaxProductRegistrationsResourceCountryOptionsSimplifiedBuilder {
52 type Out = TaxProductRegistrationsResourceCountryOptionsSimplified;
53 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
54 Ok(match k {
55 "type" => Deserialize::begin(&mut self.type_),
56
57 _ => <dyn Visitor>::ignore(),
58 })
59 }
60
61 fn deser_default() -> Self {
62 Self { type_: Deserialize::default() }
63 }
64
65 fn take_out(&mut self) -> Option<Self::Out> {
66 let (Some(type_),) = (self.type_,) else {
67 return None;
68 };
69 Some(Self::Out { type_ })
70 }
71 }
72
73 impl Map for Builder<'_> {
74 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
75 self.builder.key(k)
76 }
77
78 fn finish(&mut self) -> Result<()> {
79 *self.out = self.builder.take_out();
80 Ok(())
81 }
82 }
83
84 impl ObjectDeser for TaxProductRegistrationsResourceCountryOptionsSimplified {
85 type Builder = TaxProductRegistrationsResourceCountryOptionsSimplifiedBuilder;
86 }
87
88 impl FromValueOpt for TaxProductRegistrationsResourceCountryOptionsSimplified {
89 fn from_value(v: Value) -> Option<Self> {
90 let Value::Object(obj) = v else {
91 return None;
92 };
93 let mut b =
94 TaxProductRegistrationsResourceCountryOptionsSimplifiedBuilder::deser_default();
95 for (k, v) in obj {
96 match k.as_str() {
97 "type" => b.type_ = FromValueOpt::from_value(v),
98
99 _ => {}
100 }
101 }
102 b.take_out()
103 }
104 }
105};
106#[derive(Copy, Clone, Eq, PartialEq)]
108pub enum TaxProductRegistrationsResourceCountryOptionsSimplifiedType {
109 Simplified,
110}
111impl TaxProductRegistrationsResourceCountryOptionsSimplifiedType {
112 pub fn as_str(self) -> &'static str {
113 use TaxProductRegistrationsResourceCountryOptionsSimplifiedType::*;
114 match self {
115 Simplified => "simplified",
116 }
117 }
118}
119
120impl std::str::FromStr for TaxProductRegistrationsResourceCountryOptionsSimplifiedType {
121 type Err = stripe_types::StripeParseError;
122 fn from_str(s: &str) -> Result<Self, Self::Err> {
123 use TaxProductRegistrationsResourceCountryOptionsSimplifiedType::*;
124 match s {
125 "simplified" => Ok(Simplified),
126 _ => Err(stripe_types::StripeParseError),
127 }
128 }
129}
130impl std::fmt::Display for TaxProductRegistrationsResourceCountryOptionsSimplifiedType {
131 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
132 f.write_str(self.as_str())
133 }
134}
135
136impl std::fmt::Debug for TaxProductRegistrationsResourceCountryOptionsSimplifiedType {
137 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
138 f.write_str(self.as_str())
139 }
140}
141#[cfg(feature = "serialize")]
142impl serde::Serialize for TaxProductRegistrationsResourceCountryOptionsSimplifiedType {
143 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
144 where
145 S: serde::Serializer,
146 {
147 serializer.serialize_str(self.as_str())
148 }
149}
150impl miniserde::Deserialize for TaxProductRegistrationsResourceCountryOptionsSimplifiedType {
151 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
152 crate::Place::new(out)
153 }
154}
155
156impl miniserde::de::Visitor
157 for crate::Place<TaxProductRegistrationsResourceCountryOptionsSimplifiedType>
158{
159 fn string(&mut self, s: &str) -> miniserde::Result<()> {
160 use std::str::FromStr;
161 self.out = Some(
162 TaxProductRegistrationsResourceCountryOptionsSimplifiedType::from_str(s)
163 .map_err(|_| miniserde::Error)?,
164 );
165 Ok(())
166 }
167}
168
169stripe_types::impl_from_val_with_from_str!(
170 TaxProductRegistrationsResourceCountryOptionsSimplifiedType
171);
172#[cfg(feature = "deserialize")]
173impl<'de> serde::Deserialize<'de> for TaxProductRegistrationsResourceCountryOptionsSimplifiedType {
174 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
175 use std::str::FromStr;
176 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
177 Self::from_str(&s).map_err(|_| {
178 serde::de::Error::custom(
179 "Unknown value for TaxProductRegistrationsResourceCountryOptionsSimplifiedType",
180 )
181 })
182 }
183}