Skip to main content

stripe_shared/
setup_intent_payment_method_options_payto.rs

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 SetupIntentPaymentMethodOptionsPayto {
6    pub mandate_options: Option<stripe_shared::SetupIntentPaymentMethodOptionsMandateOptionsPayto>,
7}
8#[cfg(feature = "redact-generated-debug")]
9impl std::fmt::Debug for SetupIntentPaymentMethodOptionsPayto {
10    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
11        f.debug_struct("SetupIntentPaymentMethodOptionsPayto").finish_non_exhaustive()
12    }
13}
14#[doc(hidden)]
15pub struct SetupIntentPaymentMethodOptionsPaytoBuilder {
16    mandate_options:
17        Option<Option<stripe_shared::SetupIntentPaymentMethodOptionsMandateOptionsPayto>>,
18}
19
20#[allow(
21    unused_variables,
22    irrefutable_let_patterns,
23    clippy::let_unit_value,
24    clippy::match_single_binding,
25    clippy::single_match
26)]
27const _: () = {
28    use miniserde::de::{Map, Visitor};
29    use miniserde::json::Value;
30    use miniserde::{Deserialize, Result, make_place};
31    use stripe_types::miniserde_helpers::FromValueOpt;
32    use stripe_types::{MapBuilder, ObjectDeser};
33
34    make_place!(Place);
35
36    impl Deserialize for SetupIntentPaymentMethodOptionsPayto {
37        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
38            Place::new(out)
39        }
40    }
41
42    struct Builder<'a> {
43        out: &'a mut Option<SetupIntentPaymentMethodOptionsPayto>,
44        builder: SetupIntentPaymentMethodOptionsPaytoBuilder,
45    }
46
47    impl Visitor for Place<SetupIntentPaymentMethodOptionsPayto> {
48        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
49            Ok(Box::new(Builder {
50                out: &mut self.out,
51                builder: SetupIntentPaymentMethodOptionsPaytoBuilder::deser_default(),
52            }))
53        }
54    }
55
56    impl MapBuilder for SetupIntentPaymentMethodOptionsPaytoBuilder {
57        type Out = SetupIntentPaymentMethodOptionsPayto;
58        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
59            Ok(match k {
60                "mandate_options" => Deserialize::begin(&mut self.mandate_options),
61                _ => <dyn Visitor>::ignore(),
62            })
63        }
64
65        fn deser_default() -> Self {
66            Self { mandate_options: Deserialize::default() }
67        }
68
69        fn take_out(&mut self) -> Option<Self::Out> {
70            let (Some(mandate_options),) = (self.mandate_options.take(),) else {
71                return None;
72            };
73            Some(Self::Out { mandate_options })
74        }
75    }
76
77    impl Map for Builder<'_> {
78        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
79            self.builder.key(k)
80        }
81
82        fn finish(&mut self) -> Result<()> {
83            *self.out = self.builder.take_out();
84            Ok(())
85        }
86    }
87
88    impl ObjectDeser for SetupIntentPaymentMethodOptionsPayto {
89        type Builder = SetupIntentPaymentMethodOptionsPaytoBuilder;
90    }
91
92    impl FromValueOpt for SetupIntentPaymentMethodOptionsPayto {
93        fn from_value(v: Value) -> Option<Self> {
94            let Value::Object(obj) = v else {
95                return None;
96            };
97            let mut b = SetupIntentPaymentMethodOptionsPaytoBuilder::deser_default();
98            for (k, v) in obj {
99                match k.as_str() {
100                    "mandate_options" => b.mandate_options = FromValueOpt::from_value(v),
101                    _ => {}
102                }
103            }
104            b.take_out()
105        }
106    }
107};