stripe_shared/
issuing_physical_bundle_features.rs

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