jacquard_api/pub_leaflet/theme/
background_image.rs1#[jacquard_derive::lexicon]
9#[derive(
10 serde::Serialize,
11 serde::Deserialize,
12 Debug,
13 Clone,
14 PartialEq,
15 Eq,
16 jacquard_derive::IntoStatic
17)]
18#[serde(rename_all = "camelCase")]
19pub struct BackgroundImage<'a> {
20 #[serde(borrow)]
21 pub image: jacquard_common::types::blob::BlobRef<'a>,
22 #[serde(skip_serializing_if = "std::option::Option::is_none")]
23 pub repeat: Option<bool>,
24 #[serde(skip_serializing_if = "std::option::Option::is_none")]
25 pub width: Option<i64>,
26}
27
28pub mod background_image_state {
29
30 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
31 #[allow(unused)]
32 use ::core::marker::PhantomData;
33 mod sealed {
34 pub trait Sealed {}
35 }
36 pub trait State: sealed::Sealed {
38 type Image;
39 }
40 pub struct Empty(());
42 impl sealed::Sealed for Empty {}
43 impl State for Empty {
44 type Image = Unset;
45 }
46 pub struct SetImage<S: State = Empty>(PhantomData<fn() -> S>);
48 impl<S: State> sealed::Sealed for SetImage<S> {}
49 impl<S: State> State for SetImage<S> {
50 type Image = Set<members::image>;
51 }
52 #[allow(non_camel_case_types)]
54 pub mod members {
55 pub struct image(());
57 }
58}
59
60pub struct BackgroundImageBuilder<'a, S: background_image_state::State> {
62 _phantom_state: ::core::marker::PhantomData<fn() -> S>,
63 __unsafe_private_named: (
64 ::core::option::Option<jacquard_common::types::blob::BlobRef<'a>>,
65 ::core::option::Option<bool>,
66 ::core::option::Option<i64>,
67 ),
68 _phantom: ::core::marker::PhantomData<&'a ()>,
69}
70
71impl<'a> BackgroundImage<'a> {
72 pub fn new() -> BackgroundImageBuilder<'a, background_image_state::Empty> {
74 BackgroundImageBuilder::new()
75 }
76}
77
78impl<'a> BackgroundImageBuilder<'a, background_image_state::Empty> {
79 pub fn new() -> Self {
81 BackgroundImageBuilder {
82 _phantom_state: ::core::marker::PhantomData,
83 __unsafe_private_named: (None, None, None),
84 _phantom: ::core::marker::PhantomData,
85 }
86 }
87}
88
89impl<'a, S> BackgroundImageBuilder<'a, S>
90where
91 S: background_image_state::State,
92 S::Image: background_image_state::IsUnset,
93{
94 pub fn image(
96 mut self,
97 value: impl Into<jacquard_common::types::blob::BlobRef<'a>>,
98 ) -> BackgroundImageBuilder<'a, background_image_state::SetImage<S>> {
99 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
100 BackgroundImageBuilder {
101 _phantom_state: ::core::marker::PhantomData,
102 __unsafe_private_named: self.__unsafe_private_named,
103 _phantom: ::core::marker::PhantomData,
104 }
105 }
106}
107
108impl<'a, S: background_image_state::State> BackgroundImageBuilder<'a, S> {
109 pub fn repeat(mut self, value: impl Into<Option<bool>>) -> Self {
111 self.__unsafe_private_named.1 = value.into();
112 self
113 }
114 pub fn maybe_repeat(mut self, value: Option<bool>) -> Self {
116 self.__unsafe_private_named.1 = value;
117 self
118 }
119}
120
121impl<'a, S: background_image_state::State> BackgroundImageBuilder<'a, S> {
122 pub fn width(mut self, value: impl Into<Option<i64>>) -> Self {
124 self.__unsafe_private_named.2 = value.into();
125 self
126 }
127 pub fn maybe_width(mut self, value: Option<i64>) -> Self {
129 self.__unsafe_private_named.2 = value;
130 self
131 }
132}
133
134impl<'a, S> BackgroundImageBuilder<'a, S>
135where
136 S: background_image_state::State,
137 S::Image: background_image_state::IsSet,
138{
139 pub fn build(self) -> BackgroundImage<'a> {
141 BackgroundImage {
142 image: self.__unsafe_private_named.0.unwrap(),
143 repeat: self.__unsafe_private_named.1,
144 width: self.__unsafe_private_named.2,
145 extra_data: Default::default(),
146 }
147 }
148 pub fn build_with_data(
150 self,
151 extra_data: std::collections::BTreeMap<
152 jacquard_common::smol_str::SmolStr,
153 jacquard_common::types::value::Data<'a>,
154 >,
155 ) -> BackgroundImage<'a> {
156 BackgroundImage {
157 image: self.__unsafe_private_named.0.unwrap(),
158 repeat: self.__unsafe_private_named.1,
159 width: self.__unsafe_private_named.2,
160 extra_data: Some(extra_data),
161 }
162 }
163}
164
165fn lexicon_doc_pub_leaflet_theme_backgroundImage() -> ::jacquard_lexicon::lexicon::LexiconDoc<
166 'static,
167> {
168 ::jacquard_lexicon::lexicon::LexiconDoc {
169 lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
170 id: ::jacquard_common::CowStr::new_static("pub.leaflet.theme.backgroundImage"),
171 revision: None,
172 description: None,
173 defs: {
174 let mut map = ::std::collections::BTreeMap::new();
175 map.insert(
176 ::jacquard_common::smol_str::SmolStr::new_static("main"),
177 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
178 description: None,
179 required: Some(
180 vec![::jacquard_common::smol_str::SmolStr::new_static("image")],
181 ),
182 nullable: None,
183 properties: {
184 #[allow(unused_mut)]
185 let mut map = ::std::collections::BTreeMap::new();
186 map.insert(
187 ::jacquard_common::smol_str::SmolStr::new_static("image"),
188 ::jacquard_lexicon::lexicon::LexObjectProperty::Blob(::jacquard_lexicon::lexicon::LexBlob {
189 description: None,
190 accept: None,
191 max_size: None,
192 }),
193 );
194 map.insert(
195 ::jacquard_common::smol_str::SmolStr::new_static("repeat"),
196 ::jacquard_lexicon::lexicon::LexObjectProperty::Boolean(::jacquard_lexicon::lexicon::LexBoolean {
197 description: None,
198 default: None,
199 r#const: None,
200 }),
201 );
202 map.insert(
203 ::jacquard_common::smol_str::SmolStr::new_static("width"),
204 ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger {
205 description: None,
206 default: None,
207 minimum: None,
208 maximum: None,
209 r#enum: None,
210 r#const: None,
211 }),
212 );
213 map
214 },
215 }),
216 );
217 map
218 },
219 }
220}
221
222impl<'a> ::jacquard_lexicon::schema::LexiconSchema for BackgroundImage<'a> {
223 fn nsid() -> &'static str {
224 "pub.leaflet.theme.backgroundImage"
225 }
226 fn def_name() -> &'static str {
227 "main"
228 }
229 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
230 lexicon_doc_pub_leaflet_theme_backgroundImage()
231 }
232 fn validate(
233 &self,
234 ) -> ::std::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
235 Ok(())
236 }
237}