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