stripe_shared/
account_unification_account_controller_stripe_dashboard.rs

1#[derive(Copy, 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::{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 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
56                _ => <dyn Visitor>::ignore(),
57            })
58        }
59
60        fn deser_default() -> Self {
61            Self { type_: Deserialize::default() }
62        }
63
64        fn take_out(&mut self) -> Option<Self::Out> {
65            let (Some(type_),) = (self.type_,) else {
66                return None;
67            };
68            Some(Self::Out { type_ })
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 AccountUnificationAccountControllerStripeDashboard {
84        type Builder = AccountUnificationAccountControllerStripeDashboardBuilder;
85    }
86
87    impl FromValueOpt for AccountUnificationAccountControllerStripeDashboard {
88        fn from_value(v: Value) -> Option<Self> {
89            let Value::Object(obj) = v else {
90                return None;
91            };
92            let mut b = AccountUnificationAccountControllerStripeDashboardBuilder::deser_default();
93            for (k, v) in obj {
94                match k.as_str() {
95                    "type" => b.type_ = FromValueOpt::from_value(v),
96
97                    _ => {}
98                }
99            }
100            b.take_out()
101        }
102    }
103};
104/// A value indicating the Stripe dashboard this account has access to independent of the Connect application.
105#[derive(Copy, Clone, Eq, PartialEq)]
106pub enum AccountUnificationAccountControllerStripeDashboardType {
107    Express,
108    Full,
109    None,
110}
111impl AccountUnificationAccountControllerStripeDashboardType {
112    pub fn as_str(self) -> &'static str {
113        use AccountUnificationAccountControllerStripeDashboardType::*;
114        match self {
115            Express => "express",
116            Full => "full",
117            None => "none",
118        }
119    }
120}
121
122impl std::str::FromStr for AccountUnificationAccountControllerStripeDashboardType {
123    type Err = stripe_types::StripeParseError;
124    fn from_str(s: &str) -> Result<Self, Self::Err> {
125        use AccountUnificationAccountControllerStripeDashboardType::*;
126        match s {
127            "express" => Ok(Express),
128            "full" => Ok(Full),
129            "none" => Ok(None),
130            _ => Err(stripe_types::StripeParseError),
131        }
132    }
133}
134impl std::fmt::Display for AccountUnificationAccountControllerStripeDashboardType {
135    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
136        f.write_str(self.as_str())
137    }
138}
139
140impl std::fmt::Debug for AccountUnificationAccountControllerStripeDashboardType {
141    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
142        f.write_str(self.as_str())
143    }
144}
145#[cfg(feature = "serialize")]
146impl serde::Serialize for AccountUnificationAccountControllerStripeDashboardType {
147    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
148    where
149        S: serde::Serializer,
150    {
151        serializer.serialize_str(self.as_str())
152    }
153}
154impl miniserde::Deserialize for AccountUnificationAccountControllerStripeDashboardType {
155    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
156        crate::Place::new(out)
157    }
158}
159
160impl miniserde::de::Visitor
161    for crate::Place<AccountUnificationAccountControllerStripeDashboardType>
162{
163    fn string(&mut self, s: &str) -> miniserde::Result<()> {
164        use std::str::FromStr;
165        self.out = Some(
166            AccountUnificationAccountControllerStripeDashboardType::from_str(s)
167                .map_err(|_| miniserde::Error)?,
168        );
169        Ok(())
170    }
171}
172
173stripe_types::impl_from_val_with_from_str!(AccountUnificationAccountControllerStripeDashboardType);
174#[cfg(feature = "deserialize")]
175impl<'de> serde::Deserialize<'de> for AccountUnificationAccountControllerStripeDashboardType {
176    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
177        use std::str::FromStr;
178        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
179        Self::from_str(&s).map_err(|_| {
180            serde::de::Error::custom(
181                "Unknown value for AccountUnificationAccountControllerStripeDashboardType",
182            )
183        })
184    }
185}