stripe_shared/
issuing_transaction_fuel_data.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 IssuingTransactionFuelData {
6 pub industry_product_code: Option<String>,
8 pub quantity_decimal: Option<String>,
10 #[cfg_attr(any(feature = "deserialize", feature = "serialize"), serde(rename = "type"))]
13 pub type_: String,
14 pub unit: String,
17 pub unit_cost_decimal: String,
19}
20#[cfg(feature = "redact-generated-debug")]
21impl std::fmt::Debug for IssuingTransactionFuelData {
22 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
23 f.debug_struct("IssuingTransactionFuelData").finish_non_exhaustive()
24 }
25}
26#[doc(hidden)]
27pub struct IssuingTransactionFuelDataBuilder {
28 industry_product_code: Option<Option<String>>,
29 quantity_decimal: Option<Option<String>>,
30 type_: Option<String>,
31 unit: Option<String>,
32 unit_cost_decimal: 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 IssuingTransactionFuelData {
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<IssuingTransactionFuelData>,
59 builder: IssuingTransactionFuelDataBuilder,
60 }
61
62 impl Visitor for Place<IssuingTransactionFuelData> {
63 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
64 Ok(Box::new(Builder {
65 out: &mut self.out,
66 builder: IssuingTransactionFuelDataBuilder::deser_default(),
67 }))
68 }
69 }
70
71 impl MapBuilder for IssuingTransactionFuelDataBuilder {
72 type Out = IssuingTransactionFuelData;
73 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
74 Ok(match k {
75 "industry_product_code" => Deserialize::begin(&mut self.industry_product_code),
76 "quantity_decimal" => Deserialize::begin(&mut self.quantity_decimal),
77 "type" => Deserialize::begin(&mut self.type_),
78 "unit" => Deserialize::begin(&mut self.unit),
79 "unit_cost_decimal" => Deserialize::begin(&mut self.unit_cost_decimal),
80 _ => <dyn Visitor>::ignore(),
81 })
82 }
83
84 fn deser_default() -> Self {
85 Self {
86 industry_product_code: Some(None),
87 quantity_decimal: Some(None),
88 type_: None,
89 unit: None,
90 unit_cost_decimal: None,
91 }
92 }
93
94 fn take_out(&mut self) -> Option<Self::Out> {
95 let (
96 Some(industry_product_code),
97 Some(quantity_decimal),
98 Some(type_),
99 Some(unit),
100 Some(unit_cost_decimal),
101 ) = (
102 self.industry_product_code.take(),
103 self.quantity_decimal.take(),
104 self.type_.take(),
105 self.unit.take(),
106 self.unit_cost_decimal.take(),
107 )
108 else {
109 return None;
110 };
111 Some(Self::Out {
112 industry_product_code,
113 quantity_decimal,
114 type_,
115 unit,
116 unit_cost_decimal,
117 })
118 }
119 }
120
121 impl Map for Builder<'_> {
122 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
123 self.builder.key(k)
124 }
125
126 fn finish(&mut self) -> Result<()> {
127 *self.out = self.builder.take_out();
128 Ok(())
129 }
130 }
131
132 impl ObjectDeser for IssuingTransactionFuelData {
133 type Builder = IssuingTransactionFuelDataBuilder;
134 }
135
136 impl FromValueOpt for IssuingTransactionFuelData {
137 fn from_value(v: Value) -> Option<Self> {
138 let Value::Object(obj) = v else {
139 return None;
140 };
141 let mut b = IssuingTransactionFuelDataBuilder::deser_default();
142 for (k, v) in obj {
143 match k.as_str() {
144 "industry_product_code" => {
145 b.industry_product_code = FromValueOpt::from_value(v)
146 }
147 "quantity_decimal" => b.quantity_decimal = FromValueOpt::from_value(v),
148 "type" => b.type_ = FromValueOpt::from_value(v),
149 "unit" => b.unit = FromValueOpt::from_value(v),
150 "unit_cost_decimal" => b.unit_cost_decimal = FromValueOpt::from_value(v),
151 _ => {}
152 }
153 }
154 b.take_out()
155 }
156 }
157};