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