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