stripe_shared/
payment_method_options_customer_balance_eu_bank_account.rs1#[derive(Copy, Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct PaymentMethodOptionsCustomerBalanceEuBankAccount {
5 pub country: PaymentMethodOptionsCustomerBalanceEuBankAccountCountry,
8}
9#[doc(hidden)]
10pub struct PaymentMethodOptionsCustomerBalanceEuBankAccountBuilder {
11 country: Option<PaymentMethodOptionsCustomerBalanceEuBankAccountCountry>,
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 PaymentMethodOptionsCustomerBalanceEuBankAccount {
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<PaymentMethodOptionsCustomerBalanceEuBankAccount>,
38 builder: PaymentMethodOptionsCustomerBalanceEuBankAccountBuilder,
39 }
40
41 impl Visitor for Place<PaymentMethodOptionsCustomerBalanceEuBankAccount> {
42 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
43 Ok(Box::new(Builder {
44 out: &mut self.out,
45 builder: PaymentMethodOptionsCustomerBalanceEuBankAccountBuilder::deser_default(),
46 }))
47 }
48 }
49
50 impl MapBuilder for PaymentMethodOptionsCustomerBalanceEuBankAccountBuilder {
51 type Out = PaymentMethodOptionsCustomerBalanceEuBankAccount;
52 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
53 Ok(match k {
54 "country" => Deserialize::begin(&mut self.country),
55
56 _ => <dyn Visitor>::ignore(),
57 })
58 }
59
60 fn deser_default() -> Self {
61 Self { country: Deserialize::default() }
62 }
63
64 fn take_out(&mut self) -> Option<Self::Out> {
65 let (Some(country),) = (self.country,) else {
66 return None;
67 };
68 Some(Self::Out { country })
69 }
70 }
71
72 impl Map for Builder<'_> {
73 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
74 self.builder.key(k)
75 }
76
77 fn finish(&mut self) -> Result<()> {
78 *self.out = self.builder.take_out();
79 Ok(())
80 }
81 }
82
83 impl ObjectDeser for PaymentMethodOptionsCustomerBalanceEuBankAccount {
84 type Builder = PaymentMethodOptionsCustomerBalanceEuBankAccountBuilder;
85 }
86
87 impl FromValueOpt for PaymentMethodOptionsCustomerBalanceEuBankAccount {
88 fn from_value(v: Value) -> Option<Self> {
89 let Value::Object(obj) = v else {
90 return None;
91 };
92 let mut b = PaymentMethodOptionsCustomerBalanceEuBankAccountBuilder::deser_default();
93 for (k, v) in obj {
94 match k.as_str() {
95 "country" => b.country = FromValueOpt::from_value(v),
96
97 _ => {}
98 }
99 }
100 b.take_out()
101 }
102 }
103};
104#[derive(Copy, Clone, Eq, PartialEq)]
107pub enum PaymentMethodOptionsCustomerBalanceEuBankAccountCountry {
108 Be,
109 De,
110 Es,
111 Fr,
112 Ie,
113 Nl,
114}
115impl PaymentMethodOptionsCustomerBalanceEuBankAccountCountry {
116 pub fn as_str(self) -> &'static str {
117 use PaymentMethodOptionsCustomerBalanceEuBankAccountCountry::*;
118 match self {
119 Be => "BE",
120 De => "DE",
121 Es => "ES",
122 Fr => "FR",
123 Ie => "IE",
124 Nl => "NL",
125 }
126 }
127}
128
129impl std::str::FromStr for PaymentMethodOptionsCustomerBalanceEuBankAccountCountry {
130 type Err = stripe_types::StripeParseError;
131 fn from_str(s: &str) -> Result<Self, Self::Err> {
132 use PaymentMethodOptionsCustomerBalanceEuBankAccountCountry::*;
133 match s {
134 "BE" => Ok(Be),
135 "DE" => Ok(De),
136 "ES" => Ok(Es),
137 "FR" => Ok(Fr),
138 "IE" => Ok(Ie),
139 "NL" => Ok(Nl),
140 _ => Err(stripe_types::StripeParseError),
141 }
142 }
143}
144impl std::fmt::Display for PaymentMethodOptionsCustomerBalanceEuBankAccountCountry {
145 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
146 f.write_str(self.as_str())
147 }
148}
149
150impl std::fmt::Debug for PaymentMethodOptionsCustomerBalanceEuBankAccountCountry {
151 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
152 f.write_str(self.as_str())
153 }
154}
155#[cfg(feature = "serialize")]
156impl serde::Serialize for PaymentMethodOptionsCustomerBalanceEuBankAccountCountry {
157 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
158 where
159 S: serde::Serializer,
160 {
161 serializer.serialize_str(self.as_str())
162 }
163}
164impl miniserde::Deserialize for PaymentMethodOptionsCustomerBalanceEuBankAccountCountry {
165 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
166 crate::Place::new(out)
167 }
168}
169
170impl miniserde::de::Visitor
171 for crate::Place<PaymentMethodOptionsCustomerBalanceEuBankAccountCountry>
172{
173 fn string(&mut self, s: &str) -> miniserde::Result<()> {
174 use std::str::FromStr;
175 self.out = Some(
176 PaymentMethodOptionsCustomerBalanceEuBankAccountCountry::from_str(s)
177 .map_err(|_| miniserde::Error)?,
178 );
179 Ok(())
180 }
181}
182
183stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsCustomerBalanceEuBankAccountCountry);
184#[cfg(feature = "deserialize")]
185impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsCustomerBalanceEuBankAccountCountry {
186 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
187 use std::str::FromStr;
188 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
189 Self::from_str(&s).map_err(|_| {
190 serde::de::Error::custom(
191 "Unknown value for PaymentMethodOptionsCustomerBalanceEuBankAccountCountry",
192 )
193 })
194 }
195}