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