stripe_shared/
checkout_afterpay_clearpay_payment_method_options.rs1#[derive(Clone, Eq, PartialEq)]
2#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
3#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
4#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
5pub struct CheckoutAfterpayClearpayPaymentMethodOptions {
6 pub capture_method: Option<CheckoutAfterpayClearpayPaymentMethodOptionsCaptureMethod>,
8 pub setup_future_usage: Option<CheckoutAfterpayClearpayPaymentMethodOptionsSetupFutureUsage>,
17}
18#[cfg(feature = "redact-generated-debug")]
19impl std::fmt::Debug for CheckoutAfterpayClearpayPaymentMethodOptions {
20 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
21 f.debug_struct("CheckoutAfterpayClearpayPaymentMethodOptions").finish_non_exhaustive()
22 }
23}
24#[doc(hidden)]
25pub struct CheckoutAfterpayClearpayPaymentMethodOptionsBuilder {
26 capture_method: Option<Option<CheckoutAfterpayClearpayPaymentMethodOptionsCaptureMethod>>,
27 setup_future_usage:
28 Option<Option<CheckoutAfterpayClearpayPaymentMethodOptionsSetupFutureUsage>>,
29}
30
31#[allow(
32 unused_variables,
33 irrefutable_let_patterns,
34 clippy::let_unit_value,
35 clippy::match_single_binding,
36 clippy::single_match
37)]
38const _: () = {
39 use miniserde::de::{Map, Visitor};
40 use miniserde::json::Value;
41 use miniserde::{Deserialize, Result, make_place};
42 use stripe_types::miniserde_helpers::FromValueOpt;
43 use stripe_types::{MapBuilder, ObjectDeser};
44
45 make_place!(Place);
46
47 impl Deserialize for CheckoutAfterpayClearpayPaymentMethodOptions {
48 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
49 Place::new(out)
50 }
51 }
52
53 struct Builder<'a> {
54 out: &'a mut Option<CheckoutAfterpayClearpayPaymentMethodOptions>,
55 builder: CheckoutAfterpayClearpayPaymentMethodOptionsBuilder,
56 }
57
58 impl Visitor for Place<CheckoutAfterpayClearpayPaymentMethodOptions> {
59 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
60 Ok(Box::new(Builder {
61 out: &mut self.out,
62 builder: CheckoutAfterpayClearpayPaymentMethodOptionsBuilder::deser_default(),
63 }))
64 }
65 }
66
67 impl MapBuilder for CheckoutAfterpayClearpayPaymentMethodOptionsBuilder {
68 type Out = CheckoutAfterpayClearpayPaymentMethodOptions;
69 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
70 Ok(match k {
71 "capture_method" => Deserialize::begin(&mut self.capture_method),
72 "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage),
73 _ => <dyn Visitor>::ignore(),
74 })
75 }
76
77 fn deser_default() -> Self {
78 Self {
79 capture_method: Deserialize::default(),
80 setup_future_usage: Deserialize::default(),
81 }
82 }
83
84 fn take_out(&mut self) -> Option<Self::Out> {
85 let (Some(capture_method), Some(setup_future_usage)) =
86 (self.capture_method.take(), self.setup_future_usage.take())
87 else {
88 return None;
89 };
90 Some(Self::Out { capture_method, setup_future_usage })
91 }
92 }
93
94 impl Map for Builder<'_> {
95 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
96 self.builder.key(k)
97 }
98
99 fn finish(&mut self) -> Result<()> {
100 *self.out = self.builder.take_out();
101 Ok(())
102 }
103 }
104
105 impl ObjectDeser for CheckoutAfterpayClearpayPaymentMethodOptions {
106 type Builder = CheckoutAfterpayClearpayPaymentMethodOptionsBuilder;
107 }
108
109 impl FromValueOpt for CheckoutAfterpayClearpayPaymentMethodOptions {
110 fn from_value(v: Value) -> Option<Self> {
111 let Value::Object(obj) = v else {
112 return None;
113 };
114 let mut b = CheckoutAfterpayClearpayPaymentMethodOptionsBuilder::deser_default();
115 for (k, v) in obj {
116 match k.as_str() {
117 "capture_method" => b.capture_method = FromValueOpt::from_value(v),
118 "setup_future_usage" => b.setup_future_usage = FromValueOpt::from_value(v),
119 _ => {}
120 }
121 }
122 b.take_out()
123 }
124 }
125};
126#[derive(Clone, Eq, PartialEq)]
128#[non_exhaustive]
129pub enum CheckoutAfterpayClearpayPaymentMethodOptionsCaptureMethod {
130 Manual,
131 Unknown(String),
133}
134impl CheckoutAfterpayClearpayPaymentMethodOptionsCaptureMethod {
135 pub fn as_str(&self) -> &str {
136 use CheckoutAfterpayClearpayPaymentMethodOptionsCaptureMethod::*;
137 match self {
138 Manual => "manual",
139 Unknown(v) => v,
140 }
141 }
142}
143
144impl std::str::FromStr for CheckoutAfterpayClearpayPaymentMethodOptionsCaptureMethod {
145 type Err = std::convert::Infallible;
146 fn from_str(s: &str) -> Result<Self, Self::Err> {
147 use CheckoutAfterpayClearpayPaymentMethodOptionsCaptureMethod::*;
148 match s {
149 "manual" => Ok(Manual),
150 v => {
151 tracing::warn!(
152 "Unknown value '{}' for enum '{}'",
153 v,
154 "CheckoutAfterpayClearpayPaymentMethodOptionsCaptureMethod"
155 );
156 Ok(Unknown(v.to_owned()))
157 }
158 }
159 }
160}
161impl std::fmt::Display for CheckoutAfterpayClearpayPaymentMethodOptionsCaptureMethod {
162 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
163 f.write_str(self.as_str())
164 }
165}
166
167#[cfg(not(feature = "redact-generated-debug"))]
168impl std::fmt::Debug for CheckoutAfterpayClearpayPaymentMethodOptionsCaptureMethod {
169 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
170 f.write_str(self.as_str())
171 }
172}
173#[cfg(feature = "redact-generated-debug")]
174impl std::fmt::Debug for CheckoutAfterpayClearpayPaymentMethodOptionsCaptureMethod {
175 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
176 f.debug_struct(stringify!(CheckoutAfterpayClearpayPaymentMethodOptionsCaptureMethod))
177 .finish_non_exhaustive()
178 }
179}
180#[cfg(feature = "serialize")]
181impl serde::Serialize for CheckoutAfterpayClearpayPaymentMethodOptionsCaptureMethod {
182 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
183 where
184 S: serde::Serializer,
185 {
186 serializer.serialize_str(self.as_str())
187 }
188}
189impl miniserde::Deserialize for CheckoutAfterpayClearpayPaymentMethodOptionsCaptureMethod {
190 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
191 crate::Place::new(out)
192 }
193}
194
195impl miniserde::de::Visitor
196 for crate::Place<CheckoutAfterpayClearpayPaymentMethodOptionsCaptureMethod>
197{
198 fn string(&mut self, s: &str) -> miniserde::Result<()> {
199 use std::str::FromStr;
200 self.out = Some(
201 CheckoutAfterpayClearpayPaymentMethodOptionsCaptureMethod::from_str(s)
202 .expect("infallible"),
203 );
204 Ok(())
205 }
206}
207
208stripe_types::impl_from_val_with_from_str!(
209 CheckoutAfterpayClearpayPaymentMethodOptionsCaptureMethod
210);
211#[cfg(feature = "deserialize")]
212impl<'de> serde::Deserialize<'de> for CheckoutAfterpayClearpayPaymentMethodOptionsCaptureMethod {
213 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
214 use std::str::FromStr;
215 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
216 Ok(Self::from_str(&s).expect("infallible"))
217 }
218}
219#[derive(Clone, Eq, PartialEq)]
228#[non_exhaustive]
229pub enum CheckoutAfterpayClearpayPaymentMethodOptionsSetupFutureUsage {
230 None,
231 Unknown(String),
233}
234impl CheckoutAfterpayClearpayPaymentMethodOptionsSetupFutureUsage {
235 pub fn as_str(&self) -> &str {
236 use CheckoutAfterpayClearpayPaymentMethodOptionsSetupFutureUsage::*;
237 match self {
238 None => "none",
239 Unknown(v) => v,
240 }
241 }
242}
243
244impl std::str::FromStr for CheckoutAfterpayClearpayPaymentMethodOptionsSetupFutureUsage {
245 type Err = std::convert::Infallible;
246 fn from_str(s: &str) -> Result<Self, Self::Err> {
247 use CheckoutAfterpayClearpayPaymentMethodOptionsSetupFutureUsage::*;
248 match s {
249 "none" => Ok(None),
250 v => {
251 tracing::warn!(
252 "Unknown value '{}' for enum '{}'",
253 v,
254 "CheckoutAfterpayClearpayPaymentMethodOptionsSetupFutureUsage"
255 );
256 Ok(Unknown(v.to_owned()))
257 }
258 }
259 }
260}
261impl std::fmt::Display for CheckoutAfterpayClearpayPaymentMethodOptionsSetupFutureUsage {
262 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
263 f.write_str(self.as_str())
264 }
265}
266
267#[cfg(not(feature = "redact-generated-debug"))]
268impl std::fmt::Debug for CheckoutAfterpayClearpayPaymentMethodOptionsSetupFutureUsage {
269 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
270 f.write_str(self.as_str())
271 }
272}
273#[cfg(feature = "redact-generated-debug")]
274impl std::fmt::Debug for CheckoutAfterpayClearpayPaymentMethodOptionsSetupFutureUsage {
275 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
276 f.debug_struct(stringify!(CheckoutAfterpayClearpayPaymentMethodOptionsSetupFutureUsage))
277 .finish_non_exhaustive()
278 }
279}
280#[cfg(feature = "serialize")]
281impl serde::Serialize for CheckoutAfterpayClearpayPaymentMethodOptionsSetupFutureUsage {
282 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
283 where
284 S: serde::Serializer,
285 {
286 serializer.serialize_str(self.as_str())
287 }
288}
289impl miniserde::Deserialize for CheckoutAfterpayClearpayPaymentMethodOptionsSetupFutureUsage {
290 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
291 crate::Place::new(out)
292 }
293}
294
295impl miniserde::de::Visitor
296 for crate::Place<CheckoutAfterpayClearpayPaymentMethodOptionsSetupFutureUsage>
297{
298 fn string(&mut self, s: &str) -> miniserde::Result<()> {
299 use std::str::FromStr;
300 self.out = Some(
301 CheckoutAfterpayClearpayPaymentMethodOptionsSetupFutureUsage::from_str(s)
302 .expect("infallible"),
303 );
304 Ok(())
305 }
306}
307
308stripe_types::impl_from_val_with_from_str!(
309 CheckoutAfterpayClearpayPaymentMethodOptionsSetupFutureUsage
310);
311#[cfg(feature = "deserialize")]
312impl<'de> serde::Deserialize<'de> for CheckoutAfterpayClearpayPaymentMethodOptionsSetupFutureUsage {
313 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
314 use std::str::FromStr;
315 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
316 Ok(Self::from_str(&s).expect("infallible"))
317 }
318}