stripe_shared/
account_unification_account_controller_stripe_dashboard.rs

1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct AccountUnificationAccountControllerStripeDashboard {
5    /// A value indicating the Stripe dashboard this account has access to independent of the Connect application.
6    #[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_.take(),) 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/// A value indicating the Stripe dashboard this account has access to independent of the Connect application.
103#[derive(Clone, Eq, PartialEq)]
104#[non_exhaustive]
105pub enum AccountUnificationAccountControllerStripeDashboardType {
106    Express,
107    Full,
108    None,
109    /// An unrecognized value from Stripe. Should not be used as a request parameter.
110    Unknown(String),
111}
112impl AccountUnificationAccountControllerStripeDashboardType {
113    pub fn as_str(&self) -> &str {
114        use AccountUnificationAccountControllerStripeDashboardType::*;
115        match self {
116            Express => "express",
117            Full => "full",
118            None => "none",
119            Unknown(v) => v,
120        }
121    }
122}
123
124impl std::str::FromStr for AccountUnificationAccountControllerStripeDashboardType {
125    type Err = std::convert::Infallible;
126    fn from_str(s: &str) -> Result<Self, Self::Err> {
127        use AccountUnificationAccountControllerStripeDashboardType::*;
128        match s {
129            "express" => Ok(Express),
130            "full" => Ok(Full),
131            "none" => Ok(None),
132            v => {
133                tracing::warn!(
134                    "Unknown value '{}' for enum '{}'",
135                    v,
136                    "AccountUnificationAccountControllerStripeDashboardType"
137                );
138                Ok(Unknown(v.to_owned()))
139            }
140        }
141    }
142}
143impl std::fmt::Display for AccountUnificationAccountControllerStripeDashboardType {
144    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
145        f.write_str(self.as_str())
146    }
147}
148
149impl std::fmt::Debug for AccountUnificationAccountControllerStripeDashboardType {
150    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
151        f.write_str(self.as_str())
152    }
153}
154#[cfg(feature = "serialize")]
155impl serde::Serialize for AccountUnificationAccountControllerStripeDashboardType {
156    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
157    where
158        S: serde::Serializer,
159    {
160        serializer.serialize_str(self.as_str())
161    }
162}
163impl miniserde::Deserialize for AccountUnificationAccountControllerStripeDashboardType {
164    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
165        crate::Place::new(out)
166    }
167}
168
169impl miniserde::de::Visitor
170    for crate::Place<AccountUnificationAccountControllerStripeDashboardType>
171{
172    fn string(&mut self, s: &str) -> miniserde::Result<()> {
173        use std::str::FromStr;
174        self.out = Some(
175            AccountUnificationAccountControllerStripeDashboardType::from_str(s)
176                .expect("infallible"),
177        );
178        Ok(())
179    }
180}
181
182stripe_types::impl_from_val_with_from_str!(AccountUnificationAccountControllerStripeDashboardType);
183#[cfg(feature = "deserialize")]
184impl<'de> serde::Deserialize<'de> for AccountUnificationAccountControllerStripeDashboardType {
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}