stripe_shared/
account_unification_account_controller_fees.rs1#[derive(Copy, 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::{make_place, Deserialize, Result};
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
56 _ => <dyn Visitor>::ignore(),
57 })
58 }
59
60 fn deser_default() -> Self {
61 Self { payer: Deserialize::default() }
62 }
63
64 fn take_out(&mut self) -> Option<Self::Out> {
65 let (Some(payer),) = (self.payer,) else {
66 return None;
67 };
68 Some(Self::Out { payer })
69 }
70 }
71
72 impl<'a> Map for Builder<'a> {
73 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
74 self.builder.key(k)
75 }
76
77 fn finish(&mut self) -> Result<()> {
78 *self.out = self.builder.take_out();
79 Ok(())
80 }
81 }
82
83 impl ObjectDeser for AccountUnificationAccountControllerFees {
84 type Builder = AccountUnificationAccountControllerFeesBuilder;
85 }
86
87 impl FromValueOpt for AccountUnificationAccountControllerFees {
88 fn from_value(v: Value) -> Option<Self> {
89 let Value::Object(obj) = v else {
90 return None;
91 };
92 let mut b = AccountUnificationAccountControllerFeesBuilder::deser_default();
93 for (k, v) in obj {
94 match k.as_str() {
95 "payer" => b.payer = FromValueOpt::from_value(v),
96
97 _ => {}
98 }
99 }
100 b.take_out()
101 }
102 }
103};
104#[derive(Copy, Clone, Eq, PartialEq)]
107pub enum AccountUnificationAccountControllerFeesPayer {
108 Account,
109 Application,
110 ApplicationCustom,
111 ApplicationExpress,
112}
113impl AccountUnificationAccountControllerFeesPayer {
114 pub fn as_str(self) -> &'static str {
115 use AccountUnificationAccountControllerFeesPayer::*;
116 match self {
117 Account => "account",
118 Application => "application",
119 ApplicationCustom => "application_custom",
120 ApplicationExpress => "application_express",
121 }
122 }
123}
124
125impl std::str::FromStr for AccountUnificationAccountControllerFeesPayer {
126 type Err = stripe_types::StripeParseError;
127 fn from_str(s: &str) -> Result<Self, Self::Err> {
128 use AccountUnificationAccountControllerFeesPayer::*;
129 match s {
130 "account" => Ok(Account),
131 "application" => Ok(Application),
132 "application_custom" => Ok(ApplicationCustom),
133 "application_express" => Ok(ApplicationExpress),
134 _ => Err(stripe_types::StripeParseError),
135 }
136 }
137}
138impl std::fmt::Display for AccountUnificationAccountControllerFeesPayer {
139 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
140 f.write_str(self.as_str())
141 }
142}
143
144impl std::fmt::Debug for AccountUnificationAccountControllerFeesPayer {
145 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
146 f.write_str(self.as_str())
147 }
148}
149#[cfg(feature = "serialize")]
150impl serde::Serialize for AccountUnificationAccountControllerFeesPayer {
151 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
152 where
153 S: serde::Serializer,
154 {
155 serializer.serialize_str(self.as_str())
156 }
157}
158impl miniserde::Deserialize for AccountUnificationAccountControllerFeesPayer {
159 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
160 crate::Place::new(out)
161 }
162}
163
164impl miniserde::de::Visitor for crate::Place<AccountUnificationAccountControllerFeesPayer> {
165 fn string(&mut self, s: &str) -> miniserde::Result<()> {
166 use std::str::FromStr;
167 self.out = Some(
168 AccountUnificationAccountControllerFeesPayer::from_str(s)
169 .map_err(|_| miniserde::Error)?,
170 );
171 Ok(())
172 }
173}
174
175stripe_types::impl_from_val_with_from_str!(AccountUnificationAccountControllerFeesPayer);
176#[cfg(feature = "deserialize")]
177impl<'de> serde::Deserialize<'de> for AccountUnificationAccountControllerFeesPayer {
178 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
179 use std::str::FromStr;
180 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
181 Self::from_str(&s).map_err(|_| {
182 serde::de::Error::custom(
183 "Unknown value for AccountUnificationAccountControllerFeesPayer",
184 )
185 })
186 }
187}