stripe_shared/
payment_flows_payment_intent_async_workflows_resource_inputs.rs

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