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