stripe_shared/
billing_bill_resource_invoicing_parents_invoice_quote_parent.rs

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