stripe_shared/
payment_flows_private_payment_methods_payco_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 PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptions {
6 pub capture_method:
8 Option<PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsCaptureMethod>,
9}
10#[cfg(feature = "redact-generated-debug")]
11impl std::fmt::Debug for PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptions {
12 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
13 f.debug_struct("PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptions")
14 .finish_non_exhaustive()
15 }
16}
17#[doc(hidden)]
18pub struct PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsBuilder {
19 capture_method:
20 Option<Option<PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsCaptureMethod>>,
21}
22
23#[allow(
24 unused_variables,
25 irrefutable_let_patterns,
26 clippy::let_unit_value,
27 clippy::match_single_binding,
28 clippy::single_match
29)]
30const _: () = {
31 use miniserde::de::{Map, Visitor};
32 use miniserde::json::Value;
33 use miniserde::{Deserialize, Result, make_place};
34 use stripe_types::miniserde_helpers::FromValueOpt;
35 use stripe_types::{MapBuilder, ObjectDeser};
36
37 make_place!(Place);
38
39 impl Deserialize for PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptions {
40 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
41 Place::new(out)
42 }
43 }
44
45 struct Builder<'a> {
46 out: &'a mut Option<PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptions>,
47 builder: PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsBuilder,
48 }
49
50 impl Visitor for Place<PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptions> {
51 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
52 Ok(Box::new(Builder {
53 out: &mut self.out,
54 builder:
55 PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsBuilder::deser_default(
56 ),
57 }))
58 }
59 }
60
61 impl MapBuilder for PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsBuilder {
62 type Out = PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptions;
63 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
64 Ok(match k {
65 "capture_method" => Deserialize::begin(&mut self.capture_method),
66 _ => <dyn Visitor>::ignore(),
67 })
68 }
69
70 fn deser_default() -> Self {
71 Self { capture_method: Some(None) }
72 }
73
74 fn take_out(&mut self) -> Option<Self::Out> {
75 let (Some(capture_method),) = (self.capture_method.take(),) else {
76 return None;
77 };
78 Some(Self::Out { capture_method })
79 }
80 }
81
82 impl Map for Builder<'_> {
83 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
84 self.builder.key(k)
85 }
86
87 fn finish(&mut self) -> Result<()> {
88 *self.out = self.builder.take_out();
89 Ok(())
90 }
91 }
92
93 impl ObjectDeser for PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptions {
94 type Builder = PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsBuilder;
95 }
96
97 impl FromValueOpt for PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptions {
98 fn from_value(v: Value) -> Option<Self> {
99 let Value::Object(obj) = v else {
100 return None;
101 };
102 let mut b =
103 PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsBuilder::deser_default();
104 for (k, v) in obj {
105 match k.as_str() {
106 "capture_method" => b.capture_method = FromValueOpt::from_value(v),
107 _ => {}
108 }
109 }
110 b.take_out()
111 }
112 }
113};
114#[derive(Clone, Eq, PartialEq)]
116#[non_exhaustive]
117pub enum PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsCaptureMethod {
118 Manual,
119 Unknown(String),
121}
122impl PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsCaptureMethod {
123 pub fn as_str(&self) -> &str {
124 use PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsCaptureMethod::*;
125 match self {
126 Manual => "manual",
127 Unknown(v) => v,
128 }
129 }
130}
131
132impl std::str::FromStr for PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsCaptureMethod {
133 type Err = std::convert::Infallible;
134 fn from_str(s: &str) -> Result<Self, Self::Err> {
135 use PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsCaptureMethod::*;
136 match s {
137 "manual" => Ok(Manual),
138 v => {
139 tracing::warn!(
140 "Unknown value '{}' for enum '{}'",
141 v,
142 "PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsCaptureMethod"
143 );
144 Ok(Unknown(v.to_owned()))
145 }
146 }
147 }
148}
149impl std::fmt::Display for PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsCaptureMethod {
150 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
151 f.write_str(self.as_str())
152 }
153}
154
155#[cfg(not(feature = "redact-generated-debug"))]
156impl std::fmt::Debug for PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsCaptureMethod {
157 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
158 f.write_str(self.as_str())
159 }
160}
161#[cfg(feature = "redact-generated-debug")]
162impl std::fmt::Debug for PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsCaptureMethod {
163 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
164 f.debug_struct(stringify!(
165 PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsCaptureMethod
166 ))
167 .finish_non_exhaustive()
168 }
169}
170#[cfg(feature = "serialize")]
171impl serde::Serialize for PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsCaptureMethod {
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
180 for PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsCaptureMethod
181{
182 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
183 crate::Place::new(out)
184 }
185}
186
187impl miniserde::de::Visitor
188 for crate::Place<PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsCaptureMethod>
189{
190 fn string(&mut self, s: &str) -> miniserde::Result<()> {
191 use std::str::FromStr;
192 self.out = Some(
193 PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsCaptureMethod::from_str(s)
194 .expect("infallible"),
195 );
196 Ok(())
197 }
198}
199
200stripe_types::impl_from_val_with_from_str!(
201 PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsCaptureMethod
202);
203#[cfg(feature = "deserialize")]
204impl<'de> serde::Deserialize<'de>
205 for PaymentFlowsPrivatePaymentMethodsPaycoPaymentMethodOptionsCaptureMethod
206{
207 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
208 use std::str::FromStr;
209 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
210 Ok(Self::from_str(&s).expect("infallible"))
211 }
212}