stripe_shared/
account_unification_account_controller_fees.rs1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct AccountUnificationAccountControllerFees {
5 pub payer: AccountUnificationAccountControllerFeesPayer,
8}
9#[doc(hidden)]
10pub struct AccountUnificationAccountControllerFeesBuilder {
11 payer: Option<AccountUnificationAccountControllerFeesPayer>,
12}
13
14#[allow(
15 unused_variables,
16 irrefutable_let_patterns,
17 clippy::let_unit_value,
18 clippy::match_single_binding,
19 clippy::single_match
20)]
21const _: () = {
22 use miniserde::de::{Map, Visitor};
23 use miniserde::json::Value;
24 use miniserde::{Deserialize, Result, make_place};
25 use stripe_types::miniserde_helpers::FromValueOpt;
26 use stripe_types::{MapBuilder, ObjectDeser};
27
28 make_place!(Place);
29
30 impl Deserialize for AccountUnificationAccountControllerFees {
31 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
32 Place::new(out)
33 }
34 }
35
36 struct Builder<'a> {
37 out: &'a mut Option<AccountUnificationAccountControllerFees>,
38 builder: AccountUnificationAccountControllerFeesBuilder,
39 }
40
41 impl Visitor for Place<AccountUnificationAccountControllerFees> {
42 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
43 Ok(Box::new(Builder {
44 out: &mut self.out,
45 builder: AccountUnificationAccountControllerFeesBuilder::deser_default(),
46 }))
47 }
48 }
49
50 impl MapBuilder for AccountUnificationAccountControllerFeesBuilder {
51 type Out = AccountUnificationAccountControllerFees;
52 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
53 Ok(match k {
54 "payer" => Deserialize::begin(&mut self.payer),
55 _ => <dyn Visitor>::ignore(),
56 })
57 }
58
59 fn deser_default() -> Self {
60 Self { payer: Deserialize::default() }
61 }
62
63 fn take_out(&mut self) -> Option<Self::Out> {
64 let (Some(payer),) = (self.payer.take(),) else {
65 return None;
66 };
67 Some(Self::Out { payer })
68 }
69 }
70
71 impl Map for Builder<'_> {
72 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
73 self.builder.key(k)
74 }
75
76 fn finish(&mut self) -> Result<()> {
77 *self.out = self.builder.take_out();
78 Ok(())
79 }
80 }
81
82 impl ObjectDeser for AccountUnificationAccountControllerFees {
83 type Builder = AccountUnificationAccountControllerFeesBuilder;
84 }
85
86 impl FromValueOpt for AccountUnificationAccountControllerFees {
87 fn from_value(v: Value) -> Option<Self> {
88 let Value::Object(obj) = v else {
89 return None;
90 };
91 let mut b = AccountUnificationAccountControllerFeesBuilder::deser_default();
92 for (k, v) in obj {
93 match k.as_str() {
94 "payer" => b.payer = FromValueOpt::from_value(v),
95 _ => {}
96 }
97 }
98 b.take_out()
99 }
100 }
101};
102#[derive(Clone, Eq, PartialEq)]
105#[non_exhaustive]
106pub enum AccountUnificationAccountControllerFeesPayer {
107 Account,
108 Application,
109 ApplicationCustom,
110 ApplicationExpress,
111 Unknown(String),
113}
114impl AccountUnificationAccountControllerFeesPayer {
115 pub fn as_str(&self) -> &str {
116 use AccountUnificationAccountControllerFeesPayer::*;
117 match self {
118 Account => "account",
119 Application => "application",
120 ApplicationCustom => "application_custom",
121 ApplicationExpress => "application_express",
122 Unknown(v) => v,
123 }
124 }
125}
126
127impl std::str::FromStr for AccountUnificationAccountControllerFeesPayer {
128 type Err = std::convert::Infallible;
129 fn from_str(s: &str) -> Result<Self, Self::Err> {
130 use AccountUnificationAccountControllerFeesPayer::*;
131 match s {
132 "account" => Ok(Account),
133 "application" => Ok(Application),
134 "application_custom" => Ok(ApplicationCustom),
135 "application_express" => Ok(ApplicationExpress),
136 v => {
137 tracing::warn!(
138 "Unknown value '{}' for enum '{}'",
139 v,
140 "AccountUnificationAccountControllerFeesPayer"
141 );
142 Ok(Unknown(v.to_owned()))
143 }
144 }
145 }
146}
147impl std::fmt::Display for AccountUnificationAccountControllerFeesPayer {
148 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
149 f.write_str(self.as_str())
150 }
151}
152
153impl std::fmt::Debug for AccountUnificationAccountControllerFeesPayer {
154 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
155 f.write_str(self.as_str())
156 }
157}
158#[cfg(feature = "serialize")]
159impl serde::Serialize for AccountUnificationAccountControllerFeesPayer {
160 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
161 where
162 S: serde::Serializer,
163 {
164 serializer.serialize_str(self.as_str())
165 }
166}
167impl miniserde::Deserialize for AccountUnificationAccountControllerFeesPayer {
168 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
169 crate::Place::new(out)
170 }
171}
172
173impl miniserde::de::Visitor for crate::Place<AccountUnificationAccountControllerFeesPayer> {
174 fn string(&mut self, s: &str) -> miniserde::Result<()> {
175 use std::str::FromStr;
176 self.out =
177 Some(AccountUnificationAccountControllerFeesPayer::from_str(s).expect("infallible"));
178 Ok(())
179 }
180}
181
182stripe_types::impl_from_val_with_from_str!(AccountUnificationAccountControllerFeesPayer);
183#[cfg(feature = "deserialize")]
184impl<'de> serde::Deserialize<'de> for AccountUnificationAccountControllerFeesPayer {
185 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
186 use std::str::FromStr;
187 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
188 Ok(Self::from_str(&s).expect("infallible"))
189 }
190}