stripe_shared/
issuing_physical_bundle_features.rs

1#[derive(Copy, 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, self.carrier_text, self.second_line)
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(Copy, Clone, Eq, PartialEq)]
119pub enum IssuingPhysicalBundleFeaturesCardLogo {
120    Optional,
121    Required,
122    Unsupported,
123}
124impl IssuingPhysicalBundleFeaturesCardLogo {
125    pub fn as_str(self) -> &'static str {
126        use IssuingPhysicalBundleFeaturesCardLogo::*;
127        match self {
128            Optional => "optional",
129            Required => "required",
130            Unsupported => "unsupported",
131        }
132    }
133}
134
135impl std::str::FromStr for IssuingPhysicalBundleFeaturesCardLogo {
136    type Err = stripe_types::StripeParseError;
137    fn from_str(s: &str) -> Result<Self, Self::Err> {
138        use IssuingPhysicalBundleFeaturesCardLogo::*;
139        match s {
140            "optional" => Ok(Optional),
141            "required" => Ok(Required),
142            "unsupported" => Ok(Unsupported),
143            _ => Err(stripe_types::StripeParseError),
144        }
145    }
146}
147impl std::fmt::Display for IssuingPhysicalBundleFeaturesCardLogo {
148    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
149        f.write_str(self.as_str())
150    }
151}
152
153impl std::fmt::Debug for IssuingPhysicalBundleFeaturesCardLogo {
154    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
155        f.write_str(self.as_str())
156    }
157}
158#[cfg(feature = "serialize")]
159impl serde::Serialize for IssuingPhysicalBundleFeaturesCardLogo {
160    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
161    where
162        S: serde::Serializer,
163    {
164        serializer.serialize_str(self.as_str())
165    }
166}
167impl miniserde::Deserialize for IssuingPhysicalBundleFeaturesCardLogo {
168    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
169        crate::Place::new(out)
170    }
171}
172
173impl miniserde::de::Visitor for crate::Place<IssuingPhysicalBundleFeaturesCardLogo> {
174    fn string(&mut self, s: &str) -> miniserde::Result<()> {
175        use std::str::FromStr;
176        self.out =
177            Some(IssuingPhysicalBundleFeaturesCardLogo::from_str(s).map_err(|_| miniserde::Error)?);
178        Ok(())
179    }
180}
181
182stripe_types::impl_from_val_with_from_str!(IssuingPhysicalBundleFeaturesCardLogo);
183#[cfg(feature = "deserialize")]
184impl<'de> serde::Deserialize<'de> for IssuingPhysicalBundleFeaturesCardLogo {
185    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
186        use std::str::FromStr;
187        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
188        Self::from_str(&s).map_err(|_| {
189            serde::de::Error::custom("Unknown value for IssuingPhysicalBundleFeaturesCardLogo")
190        })
191    }
192}
193/// The policy for how to use carrier letter text in a card design with this physical bundle.
194#[derive(Copy, Clone, Eq, PartialEq)]
195pub enum IssuingPhysicalBundleFeaturesCarrierText {
196    Optional,
197    Required,
198    Unsupported,
199}
200impl IssuingPhysicalBundleFeaturesCarrierText {
201    pub fn as_str(self) -> &'static str {
202        use IssuingPhysicalBundleFeaturesCarrierText::*;
203        match self {
204            Optional => "optional",
205            Required => "required",
206            Unsupported => "unsupported",
207        }
208    }
209}
210
211impl std::str::FromStr for IssuingPhysicalBundleFeaturesCarrierText {
212    type Err = stripe_types::StripeParseError;
213    fn from_str(s: &str) -> Result<Self, Self::Err> {
214        use IssuingPhysicalBundleFeaturesCarrierText::*;
215        match s {
216            "optional" => Ok(Optional),
217            "required" => Ok(Required),
218            "unsupported" => Ok(Unsupported),
219            _ => Err(stripe_types::StripeParseError),
220        }
221    }
222}
223impl std::fmt::Display for IssuingPhysicalBundleFeaturesCarrierText {
224    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
225        f.write_str(self.as_str())
226    }
227}
228
229impl std::fmt::Debug for IssuingPhysicalBundleFeaturesCarrierText {
230    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
231        f.write_str(self.as_str())
232    }
233}
234#[cfg(feature = "serialize")]
235impl serde::Serialize for IssuingPhysicalBundleFeaturesCarrierText {
236    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
237    where
238        S: serde::Serializer,
239    {
240        serializer.serialize_str(self.as_str())
241    }
242}
243impl miniserde::Deserialize for IssuingPhysicalBundleFeaturesCarrierText {
244    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
245        crate::Place::new(out)
246    }
247}
248
249impl miniserde::de::Visitor for crate::Place<IssuingPhysicalBundleFeaturesCarrierText> {
250    fn string(&mut self, s: &str) -> miniserde::Result<()> {
251        use std::str::FromStr;
252        self.out = Some(
253            IssuingPhysicalBundleFeaturesCarrierText::from_str(s).map_err(|_| miniserde::Error)?,
254        );
255        Ok(())
256    }
257}
258
259stripe_types::impl_from_val_with_from_str!(IssuingPhysicalBundleFeaturesCarrierText);
260#[cfg(feature = "deserialize")]
261impl<'de> serde::Deserialize<'de> for IssuingPhysicalBundleFeaturesCarrierText {
262    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
263        use std::str::FromStr;
264        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
265        Self::from_str(&s).map_err(|_| {
266            serde::de::Error::custom("Unknown value for IssuingPhysicalBundleFeaturesCarrierText")
267        })
268    }
269}
270/// The policy for how to use a second line on a card with this physical bundle.
271#[derive(Copy, Clone, Eq, PartialEq)]
272pub enum IssuingPhysicalBundleFeaturesSecondLine {
273    Optional,
274    Required,
275    Unsupported,
276}
277impl IssuingPhysicalBundleFeaturesSecondLine {
278    pub fn as_str(self) -> &'static str {
279        use IssuingPhysicalBundleFeaturesSecondLine::*;
280        match self {
281            Optional => "optional",
282            Required => "required",
283            Unsupported => "unsupported",
284        }
285    }
286}
287
288impl std::str::FromStr for IssuingPhysicalBundleFeaturesSecondLine {
289    type Err = stripe_types::StripeParseError;
290    fn from_str(s: &str) -> Result<Self, Self::Err> {
291        use IssuingPhysicalBundleFeaturesSecondLine::*;
292        match s {
293            "optional" => Ok(Optional),
294            "required" => Ok(Required),
295            "unsupported" => Ok(Unsupported),
296            _ => Err(stripe_types::StripeParseError),
297        }
298    }
299}
300impl std::fmt::Display for IssuingPhysicalBundleFeaturesSecondLine {
301    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
302        f.write_str(self.as_str())
303    }
304}
305
306impl std::fmt::Debug for IssuingPhysicalBundleFeaturesSecondLine {
307    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
308        f.write_str(self.as_str())
309    }
310}
311#[cfg(feature = "serialize")]
312impl serde::Serialize for IssuingPhysicalBundleFeaturesSecondLine {
313    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
314    where
315        S: serde::Serializer,
316    {
317        serializer.serialize_str(self.as_str())
318    }
319}
320impl miniserde::Deserialize for IssuingPhysicalBundleFeaturesSecondLine {
321    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
322        crate::Place::new(out)
323    }
324}
325
326impl miniserde::de::Visitor for crate::Place<IssuingPhysicalBundleFeaturesSecondLine> {
327    fn string(&mut self, s: &str) -> miniserde::Result<()> {
328        use std::str::FromStr;
329        self.out = Some(
330            IssuingPhysicalBundleFeaturesSecondLine::from_str(s).map_err(|_| miniserde::Error)?,
331        );
332        Ok(())
333    }
334}
335
336stripe_types::impl_from_val_with_from_str!(IssuingPhysicalBundleFeaturesSecondLine);
337#[cfg(feature = "deserialize")]
338impl<'de> serde::Deserialize<'de> for IssuingPhysicalBundleFeaturesSecondLine {
339    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
340        use std::str::FromStr;
341        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
342        Self::from_str(&s).map_err(|_| {
343            serde::de::Error::custom("Unknown value for IssuingPhysicalBundleFeaturesSecondLine")
344        })
345    }
346}