stripe_shared/
account_branding_settings.rs1#[derive(Clone, Debug)]
2#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
3#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
4pub struct AccountBrandingSettings {
5 pub icon: Option<stripe_types::Expandable<stripe_shared::File>>,
8 pub logo: Option<stripe_types::Expandable<stripe_shared::File>>,
11 pub primary_color: Option<String>,
13 pub secondary_color: Option<String>,
15}
16#[doc(hidden)]
17pub struct AccountBrandingSettingsBuilder {
18 icon: Option<Option<stripe_types::Expandable<stripe_shared::File>>>,
19 logo: Option<Option<stripe_types::Expandable<stripe_shared::File>>>,
20 primary_color: Option<Option<String>>,
21 secondary_color: Option<Option<String>>,
22}
23
24#[allow(
25 unused_variables,
26 irrefutable_let_patterns,
27 clippy::let_unit_value,
28 clippy::match_single_binding,
29 clippy::single_match
30)]
31const _: () = {
32 use miniserde::de::{Map, Visitor};
33 use miniserde::json::Value;
34 use miniserde::{Deserialize, Result, make_place};
35 use stripe_types::miniserde_helpers::FromValueOpt;
36 use stripe_types::{MapBuilder, ObjectDeser};
37
38 make_place!(Place);
39
40 impl Deserialize for AccountBrandingSettings {
41 fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
42 Place::new(out)
43 }
44 }
45
46 struct Builder<'a> {
47 out: &'a mut Option<AccountBrandingSettings>,
48 builder: AccountBrandingSettingsBuilder,
49 }
50
51 impl Visitor for Place<AccountBrandingSettings> {
52 fn map(&mut self) -> Result<Box<dyn Map + '_>> {
53 Ok(Box::new(Builder {
54 out: &mut self.out,
55 builder: AccountBrandingSettingsBuilder::deser_default(),
56 }))
57 }
58 }
59
60 impl MapBuilder for AccountBrandingSettingsBuilder {
61 type Out = AccountBrandingSettings;
62 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
63 Ok(match k {
64 "icon" => Deserialize::begin(&mut self.icon),
65 "logo" => Deserialize::begin(&mut self.logo),
66 "primary_color" => Deserialize::begin(&mut self.primary_color),
67 "secondary_color" => Deserialize::begin(&mut self.secondary_color),
68 _ => <dyn Visitor>::ignore(),
69 })
70 }
71
72 fn deser_default() -> Self {
73 Self {
74 icon: Deserialize::default(),
75 logo: Deserialize::default(),
76 primary_color: Deserialize::default(),
77 secondary_color: Deserialize::default(),
78 }
79 }
80
81 fn take_out(&mut self) -> Option<Self::Out> {
82 let (Some(icon), Some(logo), Some(primary_color), Some(secondary_color)) = (
83 self.icon.take(),
84 self.logo.take(),
85 self.primary_color.take(),
86 self.secondary_color.take(),
87 ) else {
88 return None;
89 };
90 Some(Self::Out { icon, logo, primary_color, secondary_color })
91 }
92 }
93
94 impl Map for Builder<'_> {
95 fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
96 self.builder.key(k)
97 }
98
99 fn finish(&mut self) -> Result<()> {
100 *self.out = self.builder.take_out();
101 Ok(())
102 }
103 }
104
105 impl ObjectDeser for AccountBrandingSettings {
106 type Builder = AccountBrandingSettingsBuilder;
107 }
108
109 impl FromValueOpt for AccountBrandingSettings {
110 fn from_value(v: Value) -> Option<Self> {
111 let Value::Object(obj) = v else {
112 return None;
113 };
114 let mut b = AccountBrandingSettingsBuilder::deser_default();
115 for (k, v) in obj {
116 match k.as_str() {
117 "icon" => b.icon = FromValueOpt::from_value(v),
118 "logo" => b.logo = FromValueOpt::from_value(v),
119 "primary_color" => b.primary_color = FromValueOpt::from_value(v),
120 "secondary_color" => b.secondary_color = FromValueOpt::from_value(v),
121 _ => {}
122 }
123 }
124 b.take_out()
125 }
126 }
127};