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