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