jacquard_api/pub_leaflet/blocks/
image.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: pub.leaflet.blocks.image
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[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 AspectRatio<'a> {
20    pub height: i64,
21    pub width: i64,
22}
23
24pub mod aspect_ratio_state {
25
26    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
27    #[allow(unused)]
28    use ::core::marker::PhantomData;
29    mod sealed {
30        pub trait Sealed {}
31    }
32    /// State trait tracking which required fields have been set
33    pub trait State: sealed::Sealed {
34        type Width;
35        type Height;
36    }
37    /// Empty state - all required fields are unset
38    pub struct Empty(());
39    impl sealed::Sealed for Empty {}
40    impl State for Empty {
41        type Width = Unset;
42        type Height = Unset;
43    }
44    ///State transition - sets the `width` field to Set
45    pub struct SetWidth<S: State = Empty>(PhantomData<fn() -> S>);
46    impl<S: State> sealed::Sealed for SetWidth<S> {}
47    impl<S: State> State for SetWidth<S> {
48        type Width = Set<members::width>;
49        type Height = S::Height;
50    }
51    ///State transition - sets the `height` field to Set
52    pub struct SetHeight<S: State = Empty>(PhantomData<fn() -> S>);
53    impl<S: State> sealed::Sealed for SetHeight<S> {}
54    impl<S: State> State for SetHeight<S> {
55        type Width = S::Width;
56        type Height = Set<members::height>;
57    }
58    /// Marker types for field names
59    #[allow(non_camel_case_types)]
60    pub mod members {
61        ///Marker type for the `width` field
62        pub struct width(());
63        ///Marker type for the `height` field
64        pub struct height(());
65    }
66}
67
68/// Builder for constructing an instance of this type
69pub struct AspectRatioBuilder<'a, S: aspect_ratio_state::State> {
70    _phantom_state: ::core::marker::PhantomData<fn() -> S>,
71    __unsafe_private_named: (::core::option::Option<i64>, ::core::option::Option<i64>),
72    _phantom: ::core::marker::PhantomData<&'a ()>,
73}
74
75impl<'a> AspectRatio<'a> {
76    /// Create a new builder for this type
77    pub fn new() -> AspectRatioBuilder<'a, aspect_ratio_state::Empty> {
78        AspectRatioBuilder::new()
79    }
80}
81
82impl<'a> AspectRatioBuilder<'a, aspect_ratio_state::Empty> {
83    /// Create a new builder with all fields unset
84    pub fn new() -> Self {
85        AspectRatioBuilder {
86            _phantom_state: ::core::marker::PhantomData,
87            __unsafe_private_named: (None, None),
88            _phantom: ::core::marker::PhantomData,
89        }
90    }
91}
92
93impl<'a, S> AspectRatioBuilder<'a, S>
94where
95    S: aspect_ratio_state::State,
96    S::Height: aspect_ratio_state::IsUnset,
97{
98    /// Set the `height` field (required)
99    pub fn height(
100        mut self,
101        value: impl Into<i64>,
102    ) -> AspectRatioBuilder<'a, aspect_ratio_state::SetHeight<S>> {
103        self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
104        AspectRatioBuilder {
105            _phantom_state: ::core::marker::PhantomData,
106            __unsafe_private_named: self.__unsafe_private_named,
107            _phantom: ::core::marker::PhantomData,
108        }
109    }
110}
111
112impl<'a, S> AspectRatioBuilder<'a, S>
113where
114    S: aspect_ratio_state::State,
115    S::Width: aspect_ratio_state::IsUnset,
116{
117    /// Set the `width` field (required)
118    pub fn width(
119        mut self,
120        value: impl Into<i64>,
121    ) -> AspectRatioBuilder<'a, aspect_ratio_state::SetWidth<S>> {
122        self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
123        AspectRatioBuilder {
124            _phantom_state: ::core::marker::PhantomData,
125            __unsafe_private_named: self.__unsafe_private_named,
126            _phantom: ::core::marker::PhantomData,
127        }
128    }
129}
130
131impl<'a, S> AspectRatioBuilder<'a, S>
132where
133    S: aspect_ratio_state::State,
134    S::Width: aspect_ratio_state::IsSet,
135    S::Height: aspect_ratio_state::IsSet,
136{
137    /// Build the final struct
138    pub fn build(self) -> AspectRatio<'a> {
139        AspectRatio {
140            height: self.__unsafe_private_named.0.unwrap(),
141            width: self.__unsafe_private_named.1.unwrap(),
142            extra_data: Default::default(),
143        }
144    }
145    /// Build the final struct with custom extra_data
146    pub fn build_with_data(
147        self,
148        extra_data: std::collections::BTreeMap<
149            jacquard_common::smol_str::SmolStr,
150            jacquard_common::types::value::Data<'a>,
151        >,
152    ) -> AspectRatio<'a> {
153        AspectRatio {
154            height: self.__unsafe_private_named.0.unwrap(),
155            width: self.__unsafe_private_named.1.unwrap(),
156            extra_data: Some(extra_data),
157        }
158    }
159}
160
161fn lexicon_doc_pub_leaflet_blocks_image() -> ::jacquard_lexicon::lexicon::LexiconDoc<
162    'static,
163> {
164    ::jacquard_lexicon::lexicon::LexiconDoc {
165        lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
166        id: ::jacquard_common::CowStr::new_static("pub.leaflet.blocks.image"),
167        revision: None,
168        description: None,
169        defs: {
170            let mut map = ::std::collections::BTreeMap::new();
171            map.insert(
172                ::jacquard_common::smol_str::SmolStr::new_static("aspectRatio"),
173                ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
174                    description: None,
175                    required: Some(
176                        vec![
177                            ::jacquard_common::smol_str::SmolStr::new_static("width"),
178                            ::jacquard_common::smol_str::SmolStr::new_static("height")
179                        ],
180                    ),
181                    nullable: None,
182                    properties: {
183                        #[allow(unused_mut)]
184                        let mut map = ::std::collections::BTreeMap::new();
185                        map.insert(
186                            ::jacquard_common::smol_str::SmolStr::new_static("height"),
187                            ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger {
188                                description: None,
189                                default: None,
190                                minimum: None,
191                                maximum: None,
192                                r#enum: None,
193                                r#const: None,
194                            }),
195                        );
196                        map.insert(
197                            ::jacquard_common::smol_str::SmolStr::new_static("width"),
198                            ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger {
199                                description: None,
200                                default: None,
201                                minimum: None,
202                                maximum: None,
203                                r#enum: None,
204                                r#const: None,
205                            }),
206                        );
207                        map
208                    },
209                }),
210            );
211            map.insert(
212                ::jacquard_common::smol_str::SmolStr::new_static("main"),
213                ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
214                    description: None,
215                    required: Some(
216                        vec![
217                            ::jacquard_common::smol_str::SmolStr::new_static("image"),
218                            ::jacquard_common::smol_str::SmolStr::new_static("aspectRatio")
219                        ],
220                    ),
221                    nullable: None,
222                    properties: {
223                        #[allow(unused_mut)]
224                        let mut map = ::std::collections::BTreeMap::new();
225                        map.insert(
226                            ::jacquard_common::smol_str::SmolStr::new_static("alt"),
227                            ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
228                                description: Some(
229                                    ::jacquard_common::CowStr::new_static(
230                                        "Alt text description of the image, for accessibility.",
231                                    ),
232                                ),
233                                format: None,
234                                default: None,
235                                min_length: None,
236                                max_length: None,
237                                min_graphemes: None,
238                                max_graphemes: None,
239                                r#enum: None,
240                                r#const: None,
241                                known_values: None,
242                            }),
243                        );
244                        map.insert(
245                            ::jacquard_common::smol_str::SmolStr::new_static(
246                                "aspectRatio",
247                            ),
248                            ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
249                                description: None,
250                                r#ref: ::jacquard_common::CowStr::new_static("#aspectRatio"),
251                            }),
252                        );
253                        map.insert(
254                            ::jacquard_common::smol_str::SmolStr::new_static("image"),
255                            ::jacquard_lexicon::lexicon::LexObjectProperty::Blob(::jacquard_lexicon::lexicon::LexBlob {
256                                description: None,
257                                accept: None,
258                                max_size: None,
259                            }),
260                        );
261                        map
262                    },
263                }),
264            );
265            map
266        },
267    }
268}
269
270impl<'a> ::jacquard_lexicon::schema::LexiconSchema for AspectRatio<'a> {
271    fn nsid() -> &'static str {
272        "pub.leaflet.blocks.image"
273    }
274    fn def_name() -> &'static str {
275        "aspectRatio"
276    }
277    fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
278        lexicon_doc_pub_leaflet_blocks_image()
279    }
280    fn validate(
281        &self,
282    ) -> ::std::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
283        Ok(())
284    }
285}
286
287#[jacquard_derive::lexicon]
288#[derive(
289    serde::Serialize,
290    serde::Deserialize,
291    Debug,
292    Clone,
293    PartialEq,
294    Eq,
295    jacquard_derive::IntoStatic
296)]
297#[serde(rename_all = "camelCase")]
298pub struct Image<'a> {
299    /// Alt text description of the image, for accessibility.
300    #[serde(skip_serializing_if = "std::option::Option::is_none")]
301    #[serde(borrow)]
302    pub alt: Option<jacquard_common::CowStr<'a>>,
303    #[serde(borrow)]
304    pub aspect_ratio: crate::pub_leaflet::blocks::image::AspectRatio<'a>,
305    #[serde(borrow)]
306    pub image: jacquard_common::types::blob::BlobRef<'a>,
307}
308
309pub mod image_state {
310
311    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
312    #[allow(unused)]
313    use ::core::marker::PhantomData;
314    mod sealed {
315        pub trait Sealed {}
316    }
317    /// State trait tracking which required fields have been set
318    pub trait State: sealed::Sealed {
319        type Image;
320        type AspectRatio;
321    }
322    /// Empty state - all required fields are unset
323    pub struct Empty(());
324    impl sealed::Sealed for Empty {}
325    impl State for Empty {
326        type Image = Unset;
327        type AspectRatio = Unset;
328    }
329    ///State transition - sets the `image` field to Set
330    pub struct SetImage<S: State = Empty>(PhantomData<fn() -> S>);
331    impl<S: State> sealed::Sealed for SetImage<S> {}
332    impl<S: State> State for SetImage<S> {
333        type Image = Set<members::image>;
334        type AspectRatio = S::AspectRatio;
335    }
336    ///State transition - sets the `aspect_ratio` field to Set
337    pub struct SetAspectRatio<S: State = Empty>(PhantomData<fn() -> S>);
338    impl<S: State> sealed::Sealed for SetAspectRatio<S> {}
339    impl<S: State> State for SetAspectRatio<S> {
340        type Image = S::Image;
341        type AspectRatio = Set<members::aspect_ratio>;
342    }
343    /// Marker types for field names
344    #[allow(non_camel_case_types)]
345    pub mod members {
346        ///Marker type for the `image` field
347        pub struct image(());
348        ///Marker type for the `aspect_ratio` field
349        pub struct aspect_ratio(());
350    }
351}
352
353/// Builder for constructing an instance of this type
354pub struct ImageBuilder<'a, S: image_state::State> {
355    _phantom_state: ::core::marker::PhantomData<fn() -> S>,
356    __unsafe_private_named: (
357        ::core::option::Option<jacquard_common::CowStr<'a>>,
358        ::core::option::Option<crate::pub_leaflet::blocks::image::AspectRatio<'a>>,
359        ::core::option::Option<jacquard_common::types::blob::BlobRef<'a>>,
360    ),
361    _phantom: ::core::marker::PhantomData<&'a ()>,
362}
363
364impl<'a> Image<'a> {
365    /// Create a new builder for this type
366    pub fn new() -> ImageBuilder<'a, image_state::Empty> {
367        ImageBuilder::new()
368    }
369}
370
371impl<'a> ImageBuilder<'a, image_state::Empty> {
372    /// Create a new builder with all fields unset
373    pub fn new() -> Self {
374        ImageBuilder {
375            _phantom_state: ::core::marker::PhantomData,
376            __unsafe_private_named: (None, None, None),
377            _phantom: ::core::marker::PhantomData,
378        }
379    }
380}
381
382impl<'a, S: image_state::State> ImageBuilder<'a, S> {
383    /// Set the `alt` field (optional)
384    pub fn alt(mut self, value: impl Into<Option<jacquard_common::CowStr<'a>>>) -> Self {
385        self.__unsafe_private_named.0 = value.into();
386        self
387    }
388    /// Set the `alt` field to an Option value (optional)
389    pub fn maybe_alt(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self {
390        self.__unsafe_private_named.0 = value;
391        self
392    }
393}
394
395impl<'a, S> ImageBuilder<'a, S>
396where
397    S: image_state::State,
398    S::AspectRatio: image_state::IsUnset,
399{
400    /// Set the `aspectRatio` field (required)
401    pub fn aspect_ratio(
402        mut self,
403        value: impl Into<crate::pub_leaflet::blocks::image::AspectRatio<'a>>,
404    ) -> ImageBuilder<'a, image_state::SetAspectRatio<S>> {
405        self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
406        ImageBuilder {
407            _phantom_state: ::core::marker::PhantomData,
408            __unsafe_private_named: self.__unsafe_private_named,
409            _phantom: ::core::marker::PhantomData,
410        }
411    }
412}
413
414impl<'a, S> ImageBuilder<'a, S>
415where
416    S: image_state::State,
417    S::Image: image_state::IsUnset,
418{
419    /// Set the `image` field (required)
420    pub fn image(
421        mut self,
422        value: impl Into<jacquard_common::types::blob::BlobRef<'a>>,
423    ) -> ImageBuilder<'a, image_state::SetImage<S>> {
424        self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into());
425        ImageBuilder {
426            _phantom_state: ::core::marker::PhantomData,
427            __unsafe_private_named: self.__unsafe_private_named,
428            _phantom: ::core::marker::PhantomData,
429        }
430    }
431}
432
433impl<'a, S> ImageBuilder<'a, S>
434where
435    S: image_state::State,
436    S::Image: image_state::IsSet,
437    S::AspectRatio: image_state::IsSet,
438{
439    /// Build the final struct
440    pub fn build(self) -> Image<'a> {
441        Image {
442            alt: self.__unsafe_private_named.0,
443            aspect_ratio: self.__unsafe_private_named.1.unwrap(),
444            image: self.__unsafe_private_named.2.unwrap(),
445            extra_data: Default::default(),
446        }
447    }
448    /// Build the final struct with custom extra_data
449    pub fn build_with_data(
450        self,
451        extra_data: std::collections::BTreeMap<
452            jacquard_common::smol_str::SmolStr,
453            jacquard_common::types::value::Data<'a>,
454        >,
455    ) -> Image<'a> {
456        Image {
457            alt: self.__unsafe_private_named.0,
458            aspect_ratio: self.__unsafe_private_named.1.unwrap(),
459            image: self.__unsafe_private_named.2.unwrap(),
460            extra_data: Some(extra_data),
461        }
462    }
463}
464
465impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Image<'a> {
466    fn nsid() -> &'static str {
467        "pub.leaflet.blocks.image"
468    }
469    fn def_name() -> &'static str {
470        "main"
471    }
472    fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
473        lexicon_doc_pub_leaflet_blocks_image()
474    }
475    fn validate(
476        &self,
477    ) -> ::std::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
478        Ok(())
479    }
480}