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.take(), 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(Clone, Eq, PartialEq)]
126#[non_exhaustive]
127pub enum CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage {
128 None,
129 Unknown(String),
131}
132impl CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage {
133 pub fn as_str(&self) -> &str {
134 use CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage::*;
135 match self {
136 None => "none",
137 Unknown(v) => v,
138 }
139 }
140}
141
142impl std::str::FromStr for CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage {
143 type Err = std::convert::Infallible;
144 fn from_str(s: &str) -> Result<Self, Self::Err> {
145 use CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage::*;
146 match s {
147 "none" => Ok(None),
148 v => {
149 tracing::warn!(
150 "Unknown value '{}' for enum '{}'",
151 v,
152 "CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage"
153 );
154 Ok(Unknown(v.to_owned()))
155 }
156 }
157 }
158}
159impl std::fmt::Display for CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage {
160 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
161 f.write_str(self.as_str())
162 }
163}
164
165impl std::fmt::Debug for CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage {
166 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
167 f.write_str(self.as_str())
168 }
169}
170#[cfg(feature = "serialize")]
171impl serde::Serialize for CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage {
172 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
173 where
174 S: serde::Serializer,
175 {
176 serializer.serialize_str(self.as_str())
177 }
178}
179impl miniserde::Deserialize for CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage {
180 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
181 crate::Place::new(out)
182 }
183}
184
185impl miniserde::de::Visitor
186 for crate::Place<CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage>
187{
188 fn string(&mut self, s: &str) -> miniserde::Result<()> {
189 use std::str::FromStr;
190 self.out = Some(
191 CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage::from_str(s)
192 .expect("infallible"),
193 );
194 Ok(())
195 }
196}
197
198stripe_types::impl_from_val_with_from_str!(CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage);
199#[cfg(feature = "deserialize")]
200impl<'de> serde::Deserialize<'de> for CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage {
201 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
202 use std::str::FromStr;
203 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
204 Ok(Self::from_str(&s).expect("infallible"))
205 }
206}