1#[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 IssuingPhysicalBundleFeatures {
6 pub card_logo: IssuingPhysicalBundleFeaturesCardLogo,
8 pub carrier_text: IssuingPhysicalBundleFeaturesCarrierText,
10 pub second_line: IssuingPhysicalBundleFeaturesSecondLine,
12}
13#[cfg(feature = "redact-generated-debug")]
14impl std::fmt::Debug for IssuingPhysicalBundleFeatures {
15 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
16 f.debug_struct("IssuingPhysicalBundleFeatures").finish_non_exhaustive()
17 }
18}
19#[doc(hidden)]
20pub struct IssuingPhysicalBundleFeaturesBuilder {
21 card_logo: Option<IssuingPhysicalBundleFeaturesCardLogo>,
22 carrier_text: Option<IssuingPhysicalBundleFeaturesCarrierText>,
23 second_line: Option<IssuingPhysicalBundleFeaturesSecondLine>,
24}
25
26#[allow(
27 unused_variables,
28 irrefutable_let_patterns,
29 clippy::let_unit_value,
30 clippy::match_single_binding,
31 clippy::single_match
32)]
33const _: () = {
34 use miniserde::de::{Map, Visitor};
35 use miniserde::json::Value;
36 use miniserde::{Deserialize, Result, make_place};
37 use stripe_types::miniserde_helpers::FromValueOpt;
38 use stripe_types::{MapBuilder, ObjectDeser};
39
40 make_place!(Place);
41
42 impl Deserialize for IssuingPhysicalBundleFeatures {
43 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
44 Place::new(out)
45 }
46 }
47
48 struct Builder<'a> {
49 out: &'a mut Option<IssuingPhysicalBundleFeatures>,
50 builder: IssuingPhysicalBundleFeaturesBuilder,
51 }
52
53 impl Visitor for Place<IssuingPhysicalBundleFeatures> {
54 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
55 Ok(Box::new(Builder {
56 out: &mut self.out,
57 builder: IssuingPhysicalBundleFeaturesBuilder::deser_default(),
58 }))
59 }
60 }
61
62 impl MapBuilder for IssuingPhysicalBundleFeaturesBuilder {
63 type Out = IssuingPhysicalBundleFeatures;
64 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
65 Ok(match k {
66 "card_logo" => Deserialize::begin(&mut self.card_logo),
67 "carrier_text" => Deserialize::begin(&mut self.carrier_text),
68 "second_line" => Deserialize::begin(&mut self.second_line),
69 _ => <dyn Visitor>::ignore(),
70 })
71 }
72
73 fn deser_default() -> Self {
74 Self { card_logo: None, carrier_text: None, second_line: None }
75 }
76
77 fn take_out(&mut self) -> Option<Self::Out> {
78 let (Some(card_logo), Some(carrier_text), Some(second_line)) =
79 (self.card_logo.take(), self.carrier_text.take(), self.second_line.take())
80 else {
81 return None;
82 };
83 Some(Self::Out { card_logo, carrier_text, second_line })
84 }
85 }
86
87 impl Map for Builder<'_> {
88 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
89 self.builder.key(k)
90 }
91
92 fn finish(&mut self) -> Result<()> {
93 *self.out = self.builder.take_out();
94 Ok(())
95 }
96 }
97
98 impl ObjectDeser for IssuingPhysicalBundleFeatures {
99 type Builder = IssuingPhysicalBundleFeaturesBuilder;
100 }
101
102 impl FromValueOpt for IssuingPhysicalBundleFeatures {
103 fn from_value(v: Value) -> Option<Self> {
104 let Value::Object(obj) = v else {
105 return None;
106 };
107 let mut b = IssuingPhysicalBundleFeaturesBuilder::deser_default();
108 for (k, v) in obj {
109 match k.as_str() {
110 "card_logo" => b.card_logo = FromValueOpt::from_value(v),
111 "carrier_text" => b.carrier_text = FromValueOpt::from_value(v),
112 "second_line" => b.second_line = FromValueOpt::from_value(v),
113 _ => {}
114 }
115 }
116 b.take_out()
117 }
118 }
119};
120#[derive(Clone, Eq, PartialEq)]
122#[non_exhaustive]
123pub enum IssuingPhysicalBundleFeaturesCardLogo {
124 Optional,
125 Required,
126 Unsupported,
127 Unknown(String),
129}
130impl IssuingPhysicalBundleFeaturesCardLogo {
131 pub fn as_str(&self) -> &str {
132 use IssuingPhysicalBundleFeaturesCardLogo::*;
133 match self {
134 Optional => "optional",
135 Required => "required",
136 Unsupported => "unsupported",
137 Unknown(v) => v,
138 }
139 }
140}
141
142impl std::str::FromStr for IssuingPhysicalBundleFeaturesCardLogo {
143 type Err = std::convert::Infallible;
144 fn from_str(s: &str) -> Result<Self, Self::Err> {
145 use IssuingPhysicalBundleFeaturesCardLogo::*;
146 match s {
147 "optional" => Ok(Optional),
148 "required" => Ok(Required),
149 "unsupported" => Ok(Unsupported),
150 v => {
151 tracing::warn!(
152 "Unknown value '{}' for enum '{}'",
153 v,
154 "IssuingPhysicalBundleFeaturesCardLogo"
155 );
156 Ok(Unknown(v.to_owned()))
157 }
158 }
159 }
160}
161impl std::fmt::Display for IssuingPhysicalBundleFeaturesCardLogo {
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 IssuingPhysicalBundleFeaturesCardLogo {
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 IssuingPhysicalBundleFeaturesCardLogo {
175 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
176 f.debug_struct(stringify!(IssuingPhysicalBundleFeaturesCardLogo)).finish_non_exhaustive()
177 }
178}
179#[cfg(feature = "serialize")]
180impl serde::Serialize for IssuingPhysicalBundleFeaturesCardLogo {
181 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
182 where
183 S: serde::Serializer,
184 {
185 serializer.serialize_str(self.as_str())
186 }
187}
188impl miniserde::Deserialize for IssuingPhysicalBundleFeaturesCardLogo {
189 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
190 crate::Place::new(out)
191 }
192}
193
194impl miniserde::de::Visitor for crate::Place<IssuingPhysicalBundleFeaturesCardLogo> {
195 fn string(&mut self, s: &str) -> miniserde::Result<()> {
196 use std::str::FromStr;
197 self.out = Some(IssuingPhysicalBundleFeaturesCardLogo::from_str(s).expect("infallible"));
198 Ok(())
199 }
200}
201
202stripe_types::impl_from_val_with_from_str!(IssuingPhysicalBundleFeaturesCardLogo);
203#[cfg(feature = "deserialize")]
204impl<'de> serde::Deserialize<'de> for IssuingPhysicalBundleFeaturesCardLogo {
205 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
206 use std::str::FromStr;
207 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
208 Ok(Self::from_str(&s).expect("infallible"))
209 }
210}
211#[derive(Clone, Eq, PartialEq)]
213#[non_exhaustive]
214pub enum IssuingPhysicalBundleFeaturesCarrierText {
215 Optional,
216 Required,
217 Unsupported,
218 Unknown(String),
220}
221impl IssuingPhysicalBundleFeaturesCarrierText {
222 pub fn as_str(&self) -> &str {
223 use IssuingPhysicalBundleFeaturesCarrierText::*;
224 match self {
225 Optional => "optional",
226 Required => "required",
227 Unsupported => "unsupported",
228 Unknown(v) => v,
229 }
230 }
231}
232
233impl std::str::FromStr for IssuingPhysicalBundleFeaturesCarrierText {
234 type Err = std::convert::Infallible;
235 fn from_str(s: &str) -> Result<Self, Self::Err> {
236 use IssuingPhysicalBundleFeaturesCarrierText::*;
237 match s {
238 "optional" => Ok(Optional),
239 "required" => Ok(Required),
240 "unsupported" => Ok(Unsupported),
241 v => {
242 tracing::warn!(
243 "Unknown value '{}' for enum '{}'",
244 v,
245 "IssuingPhysicalBundleFeaturesCarrierText"
246 );
247 Ok(Unknown(v.to_owned()))
248 }
249 }
250 }
251}
252impl std::fmt::Display for IssuingPhysicalBundleFeaturesCarrierText {
253 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
254 f.write_str(self.as_str())
255 }
256}
257
258#[cfg(not(feature = "redact-generated-debug"))]
259impl std::fmt::Debug for IssuingPhysicalBundleFeaturesCarrierText {
260 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
261 f.write_str(self.as_str())
262 }
263}
264#[cfg(feature = "redact-generated-debug")]
265impl std::fmt::Debug for IssuingPhysicalBundleFeaturesCarrierText {
266 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
267 f.debug_struct(stringify!(IssuingPhysicalBundleFeaturesCarrierText)).finish_non_exhaustive()
268 }
269}
270#[cfg(feature = "serialize")]
271impl serde::Serialize for IssuingPhysicalBundleFeaturesCarrierText {
272 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
273 where
274 S: serde::Serializer,
275 {
276 serializer.serialize_str(self.as_str())
277 }
278}
279impl miniserde::Deserialize for IssuingPhysicalBundleFeaturesCarrierText {
280 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
281 crate::Place::new(out)
282 }
283}
284
285impl miniserde::de::Visitor for crate::Place<IssuingPhysicalBundleFeaturesCarrierText> {
286 fn string(&mut self, s: &str) -> miniserde::Result<()> {
287 use std::str::FromStr;
288 self.out = Some(IssuingPhysicalBundleFeaturesCarrierText::from_str(s).expect("infallible"));
289 Ok(())
290 }
291}
292
293stripe_types::impl_from_val_with_from_str!(IssuingPhysicalBundleFeaturesCarrierText);
294#[cfg(feature = "deserialize")]
295impl<'de> serde::Deserialize<'de> for IssuingPhysicalBundleFeaturesCarrierText {
296 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
297 use std::str::FromStr;
298 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
299 Ok(Self::from_str(&s).expect("infallible"))
300 }
301}
302#[derive(Clone, Eq, PartialEq)]
304#[non_exhaustive]
305pub enum IssuingPhysicalBundleFeaturesSecondLine {
306 Optional,
307 Required,
308 Unsupported,
309 Unknown(String),
311}
312impl IssuingPhysicalBundleFeaturesSecondLine {
313 pub fn as_str(&self) -> &str {
314 use IssuingPhysicalBundleFeaturesSecondLine::*;
315 match self {
316 Optional => "optional",
317 Required => "required",
318 Unsupported => "unsupported",
319 Unknown(v) => v,
320 }
321 }
322}
323
324impl std::str::FromStr for IssuingPhysicalBundleFeaturesSecondLine {
325 type Err = std::convert::Infallible;
326 fn from_str(s: &str) -> Result<Self, Self::Err> {
327 use IssuingPhysicalBundleFeaturesSecondLine::*;
328 match s {
329 "optional" => Ok(Optional),
330 "required" => Ok(Required),
331 "unsupported" => Ok(Unsupported),
332 v => {
333 tracing::warn!(
334 "Unknown value '{}' for enum '{}'",
335 v,
336 "IssuingPhysicalBundleFeaturesSecondLine"
337 );
338 Ok(Unknown(v.to_owned()))
339 }
340 }
341 }
342}
343impl std::fmt::Display for IssuingPhysicalBundleFeaturesSecondLine {
344 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
345 f.write_str(self.as_str())
346 }
347}
348
349#[cfg(not(feature = "redact-generated-debug"))]
350impl std::fmt::Debug for IssuingPhysicalBundleFeaturesSecondLine {
351 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
352 f.write_str(self.as_str())
353 }
354}
355#[cfg(feature = "redact-generated-debug")]
356impl std::fmt::Debug for IssuingPhysicalBundleFeaturesSecondLine {
357 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
358 f.debug_struct(stringify!(IssuingPhysicalBundleFeaturesSecondLine)).finish_non_exhaustive()
359 }
360}
361#[cfg(feature = "serialize")]
362impl serde::Serialize for IssuingPhysicalBundleFeaturesSecondLine {
363 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
364 where
365 S: serde::Serializer,
366 {
367 serializer.serialize_str(self.as_str())
368 }
369}
370impl miniserde::Deserialize for IssuingPhysicalBundleFeaturesSecondLine {
371 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
372 crate::Place::new(out)
373 }
374}
375
376impl miniserde::de::Visitor for crate::Place<IssuingPhysicalBundleFeaturesSecondLine> {
377 fn string(&mut self, s: &str) -> miniserde::Result<()> {
378 use std::str::FromStr;
379 self.out = Some(IssuingPhysicalBundleFeaturesSecondLine::from_str(s).expect("infallible"));
380 Ok(())
381 }
382}
383
384stripe_types::impl_from_val_with_from_str!(IssuingPhysicalBundleFeaturesSecondLine);
385#[cfg(feature = "deserialize")]
386impl<'de> serde::Deserialize<'de> for IssuingPhysicalBundleFeaturesSecondLine {
387 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
388 use std::str::FromStr;
389 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
390 Ok(Self::from_str(&s).expect("infallible"))
391 }
392}