stripe_shared/
invoice_setting_customer_setting.rs1#[derive(Clone)]
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 InvoiceSettingCustomerSetting {
6 pub custom_fields: Option<Vec<stripe_shared::InvoiceSettingCustomField>>,
8 pub default_payment_method: Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>,
10 pub footer: Option<String>,
12 pub rendering_options: Option<stripe_shared::InvoiceSettingCustomerRenderingOptions>,
14}
15#[cfg(feature = "redact-generated-debug")]
16impl std::fmt::Debug for InvoiceSettingCustomerSetting {
17 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
18 f.debug_struct("InvoiceSettingCustomerSetting").finish_non_exhaustive()
19 }
20}
21#[doc(hidden)]
22pub struct InvoiceSettingCustomerSettingBuilder {
23 custom_fields: Option<Option<Vec<stripe_shared::InvoiceSettingCustomField>>>,
24 default_payment_method: Option<Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>>,
25 footer: Option<Option<String>>,
26 rendering_options: Option<Option<stripe_shared::InvoiceSettingCustomerRenderingOptions>>,
27}
28
29#[allow(
30 unused_variables,
31 irrefutable_let_patterns,
32 clippy::let_unit_value,
33 clippy::match_single_binding,
34 clippy::single_match
35)]
36const _: () = {
37 use miniserde::de::{Map, Visitor};
38 use miniserde::json::Value;
39 use miniserde::{Deserialize, Result, make_place};
40 use stripe_types::miniserde_helpers::FromValueOpt;
41 use stripe_types::{MapBuilder, ObjectDeser};
42
43 make_place!(Place);
44
45 impl Deserialize for InvoiceSettingCustomerSetting {
46 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
47 Place::new(out)
48 }
49 }
50
51 struct Builder<'a> {
52 out: &'a mut Option<InvoiceSettingCustomerSetting>,
53 builder: InvoiceSettingCustomerSettingBuilder,
54 }
55
56 impl Visitor for Place<InvoiceSettingCustomerSetting> {
57 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
58 Ok(Box::new(Builder {
59 out: &mut self.out,
60 builder: InvoiceSettingCustomerSettingBuilder::deser_default(),
61 }))
62 }
63 }
64
65 impl MapBuilder for InvoiceSettingCustomerSettingBuilder {
66 type Out = InvoiceSettingCustomerSetting;
67 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
68 Ok(match k {
69 "custom_fields" => Deserialize::begin(&mut self.custom_fields),
70 "default_payment_method" => Deserialize::begin(&mut self.default_payment_method),
71 "footer" => Deserialize::begin(&mut self.footer),
72 "rendering_options" => Deserialize::begin(&mut self.rendering_options),
73 _ => <dyn Visitor>::ignore(),
74 })
75 }
76
77 fn deser_default() -> Self {
78 Self {
79 custom_fields: Some(None),
80 default_payment_method: Some(None),
81 footer: Some(None),
82 rendering_options: Some(None),
83 }
84 }
85
86 fn take_out(&mut self) -> Option<Self::Out> {
87 let (
88 Some(custom_fields),
89 Some(default_payment_method),
90 Some(footer),
91 Some(rendering_options),
92 ) = (
93 self.custom_fields.take(),
94 self.default_payment_method.take(),
95 self.footer.take(),
96 self.rendering_options.take(),
97 )
98 else {
99 return None;
100 };
101 Some(Self::Out { custom_fields, default_payment_method, footer, rendering_options })
102 }
103 }
104
105 impl Map for Builder<'_> {
106 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
107 self.builder.key(k)
108 }
109
110 fn finish(&mut self) -> Result<()> {
111 *self.out = self.builder.take_out();
112 Ok(())
113 }
114 }
115
116 impl ObjectDeser for InvoiceSettingCustomerSetting {
117 type Builder = InvoiceSettingCustomerSettingBuilder;
118 }
119
120 impl FromValueOpt for InvoiceSettingCustomerSetting {
121 fn from_value(v: Value) -> Option<Self> {
122 let Value::Object(obj) = v else {
123 return None;
124 };
125 let mut b = InvoiceSettingCustomerSettingBuilder::deser_default();
126 for (k, v) in obj {
127 match k.as_str() {
128 "custom_fields" => b.custom_fields = FromValueOpt::from_value(v),
129 "default_payment_method" => {
130 b.default_payment_method = FromValueOpt::from_value(v)
131 }
132 "footer" => b.footer = FromValueOpt::from_value(v),
133 "rendering_options" => b.rendering_options = FromValueOpt::from_value(v),
134 _ => {}
135 }
136 }
137 b.take_out()
138 }
139 }
140};