stripe_shared/
account_unification_account_controller_stripe_dashboard.rs1#[derive(Copy, Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct AccountUnificationAccountControllerStripeDashboard {
5 #[cfg_attr(any(feature = "deserialize", feature = "serialize"), serde(rename = "type"))]
7 pub type_: AccountUnificationAccountControllerStripeDashboardType,
8}
9#[doc(hidden)]
10pub struct AccountUnificationAccountControllerStripeDashboardBuilder {
11 type_: Option<AccountUnificationAccountControllerStripeDashboardType>,
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 AccountUnificationAccountControllerStripeDashboard {
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<AccountUnificationAccountControllerStripeDashboard>,
38 builder: AccountUnificationAccountControllerStripeDashboardBuilder,
39 }
40
41 impl Visitor for Place<AccountUnificationAccountControllerStripeDashboard> {
42 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
43 Ok(Box::new(Builder {
44 out: &mut self.out,
45 builder: AccountUnificationAccountControllerStripeDashboardBuilder::deser_default(),
46 }))
47 }
48 }
49
50 impl MapBuilder for AccountUnificationAccountControllerStripeDashboardBuilder {
51 type Out = AccountUnificationAccountControllerStripeDashboard;
52 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
53 Ok(match k {
54 "type" => Deserialize::begin(&mut self.type_),
55 _ => <dyn Visitor>::ignore(),
56 })
57 }
58
59 fn deser_default() -> Self {
60 Self { type_: Deserialize::default() }
61 }
62
63 fn take_out(&mut self) -> Option<Self::Out> {
64 let (Some(type_),) = (self.type_,) else {
65 return None;
66 };
67 Some(Self::Out { type_ })
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 AccountUnificationAccountControllerStripeDashboard {
83 type Builder = AccountUnificationAccountControllerStripeDashboardBuilder;
84 }
85
86 impl FromValueOpt for AccountUnificationAccountControllerStripeDashboard {
87 fn from_value(v: Value) -> Option<Self> {
88 let Value::Object(obj) = v else {
89 return None;
90 };
91 let mut b = AccountUnificationAccountControllerStripeDashboardBuilder::deser_default();
92 for (k, v) in obj {
93 match k.as_str() {
94 "type" => b.type_ = FromValueOpt::from_value(v),
95 _ => {}
96 }
97 }
98 b.take_out()
99 }
100 }
101};
102#[derive(Copy, Clone, Eq, PartialEq)]
104pub enum AccountUnificationAccountControllerStripeDashboardType {
105 Express,
106 Full,
107 None,
108}
109impl AccountUnificationAccountControllerStripeDashboardType {
110 pub fn as_str(self) -> &'static str {
111 use AccountUnificationAccountControllerStripeDashboardType::*;
112 match self {
113 Express => "express",
114 Full => "full",
115 None => "none",
116 }
117 }
118}
119
120impl std::str::FromStr for AccountUnificationAccountControllerStripeDashboardType {
121 type Err = stripe_types::StripeParseError;
122 fn from_str(s: &str) -> Result<Self, Self::Err> {
123 use AccountUnificationAccountControllerStripeDashboardType::*;
124 match s {
125 "express" => Ok(Express),
126 "full" => Ok(Full),
127 "none" => Ok(None),
128 _ => Err(stripe_types::StripeParseError),
129 }
130 }
131}
132impl std::fmt::Display for AccountUnificationAccountControllerStripeDashboardType {
133 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
134 f.write_str(self.as_str())
135 }
136}
137
138impl std::fmt::Debug for AccountUnificationAccountControllerStripeDashboardType {
139 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
140 f.write_str(self.as_str())
141 }
142}
143#[cfg(feature = "serialize")]
144impl serde::Serialize for AccountUnificationAccountControllerStripeDashboardType {
145 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
146 where
147 S: serde::Serializer,
148 {
149 serializer.serialize_str(self.as_str())
150 }
151}
152impl miniserde::Deserialize for AccountUnificationAccountControllerStripeDashboardType {
153 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
154 crate::Place::new(out)
155 }
156}
157
158impl miniserde::de::Visitor
159 for crate::Place<AccountUnificationAccountControllerStripeDashboardType>
160{
161 fn string(&mut self, s: &str) -> miniserde::Result<()> {
162 use std::str::FromStr;
163 self.out = Some(
164 AccountUnificationAccountControllerStripeDashboardType::from_str(s)
165 .map_err(|_| miniserde::Error)?,
166 );
167 Ok(())
168 }
169}
170
171stripe_types::impl_from_val_with_from_str!(AccountUnificationAccountControllerStripeDashboardType);
172#[cfg(feature = "deserialize")]
173impl<'de> serde::Deserialize<'de> for AccountUnificationAccountControllerStripeDashboardType {
174 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
175 use std::str::FromStr;
176 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
177 Self::from_str(&s).map_err(|_| {
178 serde::de::Error::custom(
179 "Unknown value for AccountUnificationAccountControllerStripeDashboardType",
180 )
181 })
182 }
183}