jacquard_api/pub_leaflet/blocks/
unordered_list.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: pub.leaflet.blocks.unorderedList
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 ListItem<'a> {
20    #[serde(skip_serializing_if = "std::option::Option::is_none")]
21    #[serde(borrow)]
22    pub children: Option<Vec<crate::pub_leaflet::blocks::unordered_list::ListItem<'a>>>,
23    #[serde(borrow)]
24    pub content: ListItemContent<'a>,
25}
26
27pub mod list_item_state {
28
29    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
30    #[allow(unused)]
31    use ::core::marker::PhantomData;
32    mod sealed {
33        pub trait Sealed {}
34    }
35    /// State trait tracking which required fields have been set
36    pub trait State: sealed::Sealed {
37        type Content;
38    }
39    /// Empty state - all required fields are unset
40    pub struct Empty(());
41    impl sealed::Sealed for Empty {}
42    impl State for Empty {
43        type Content = Unset;
44    }
45    ///State transition - sets the `content` field to Set
46    pub struct SetContent<S: State = Empty>(PhantomData<fn() -> S>);
47    impl<S: State> sealed::Sealed for SetContent<S> {}
48    impl<S: State> State for SetContent<S> {
49        type Content = Set<members::content>;
50    }
51    /// Marker types for field names
52    #[allow(non_camel_case_types)]
53    pub mod members {
54        ///Marker type for the `content` field
55        pub struct content(());
56    }
57}
58
59/// Builder for constructing an instance of this type
60pub struct ListItemBuilder<'a, S: list_item_state::State> {
61    _phantom_state: ::core::marker::PhantomData<fn() -> S>,
62    __unsafe_private_named: (
63        ::core::option::Option<
64            Vec<crate::pub_leaflet::blocks::unordered_list::ListItem<'a>>,
65        >,
66        ::core::option::Option<ListItemContent<'a>>,
67    ),
68    _phantom: ::core::marker::PhantomData<&'a ()>,
69}
70
71impl<'a> ListItem<'a> {
72    /// Create a new builder for this type
73    pub fn new() -> ListItemBuilder<'a, list_item_state::Empty> {
74        ListItemBuilder::new()
75    }
76}
77
78impl<'a> ListItemBuilder<'a, list_item_state::Empty> {
79    /// Create a new builder with all fields unset
80    pub fn new() -> Self {
81        ListItemBuilder {
82            _phantom_state: ::core::marker::PhantomData,
83            __unsafe_private_named: (None, None),
84            _phantom: ::core::marker::PhantomData,
85        }
86    }
87}
88
89impl<'a, S: list_item_state::State> ListItemBuilder<'a, S> {
90    /// Set the `children` field (optional)
91    pub fn children(
92        mut self,
93        value: impl Into<
94            Option<Vec<crate::pub_leaflet::blocks::unordered_list::ListItem<'a>>>,
95        >,
96    ) -> Self {
97        self.__unsafe_private_named.0 = value.into();
98        self
99    }
100    /// Set the `children` field to an Option value (optional)
101    pub fn maybe_children(
102        mut self,
103        value: Option<Vec<crate::pub_leaflet::blocks::unordered_list::ListItem<'a>>>,
104    ) -> Self {
105        self.__unsafe_private_named.0 = value;
106        self
107    }
108}
109
110impl<'a, S> ListItemBuilder<'a, S>
111where
112    S: list_item_state::State,
113    S::Content: list_item_state::IsUnset,
114{
115    /// Set the `content` field (required)
116    pub fn content(
117        mut self,
118        value: impl Into<ListItemContent<'a>>,
119    ) -> ListItemBuilder<'a, list_item_state::SetContent<S>> {
120        self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
121        ListItemBuilder {
122            _phantom_state: ::core::marker::PhantomData,
123            __unsafe_private_named: self.__unsafe_private_named,
124            _phantom: ::core::marker::PhantomData,
125        }
126    }
127}
128
129impl<'a, S> ListItemBuilder<'a, S>
130where
131    S: list_item_state::State,
132    S::Content: list_item_state::IsSet,
133{
134    /// Build the final struct
135    pub fn build(self) -> ListItem<'a> {
136        ListItem {
137            children: self.__unsafe_private_named.0,
138            content: self.__unsafe_private_named.1.unwrap(),
139            extra_data: Default::default(),
140        }
141    }
142    /// Build the final struct with custom extra_data
143    pub fn build_with_data(
144        self,
145        extra_data: std::collections::BTreeMap<
146            jacquard_common::smol_str::SmolStr,
147            jacquard_common::types::value::Data<'a>,
148        >,
149    ) -> ListItem<'a> {
150        ListItem {
151            children: self.__unsafe_private_named.0,
152            content: self.__unsafe_private_named.1.unwrap(),
153            extra_data: Some(extra_data),
154        }
155    }
156}
157
158#[jacquard_derive::open_union]
159#[derive(
160    serde::Serialize,
161    serde::Deserialize,
162    Debug,
163    Clone,
164    PartialEq,
165    Eq,
166    jacquard_derive::IntoStatic
167)]
168#[serde(tag = "$type")]
169#[serde(bound(deserialize = "'de: 'a"))]
170pub enum ListItemContent<'a> {
171    #[serde(rename = "pub.leaflet.blocks.text")]
172    Text(Box<crate::pub_leaflet::blocks::text::Text<'a>>),
173    #[serde(rename = "pub.leaflet.blocks.header")]
174    Header(Box<crate::pub_leaflet::blocks::header::Header<'a>>),
175    #[serde(rename = "pub.leaflet.blocks.image")]
176    Image(Box<crate::pub_leaflet::blocks::image::Image<'a>>),
177}
178
179fn lexicon_doc_pub_leaflet_blocks_unorderedList() -> ::jacquard_lexicon::lexicon::LexiconDoc<
180    'static,
181> {
182    ::jacquard_lexicon::lexicon::LexiconDoc {
183        lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
184        id: ::jacquard_common::CowStr::new_static("pub.leaflet.blocks.unorderedList"),
185        revision: None,
186        description: None,
187        defs: {
188            let mut map = ::std::collections::BTreeMap::new();
189            map.insert(
190                ::jacquard_common::smol_str::SmolStr::new_static("listItem"),
191                ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
192                    description: None,
193                    required: Some(
194                        vec![::jacquard_common::smol_str::SmolStr::new_static("content")],
195                    ),
196                    nullable: None,
197                    properties: {
198                        #[allow(unused_mut)]
199                        let mut map = ::std::collections::BTreeMap::new();
200                        map.insert(
201                            ::jacquard_common::smol_str::SmolStr::new_static("children"),
202                            ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
203                                description: None,
204                                items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef {
205                                    description: None,
206                                    r#ref: ::jacquard_common::CowStr::new_static("#listItem"),
207                                }),
208                                min_length: None,
209                                max_length: None,
210                            }),
211                        );
212                        map.insert(
213                            ::jacquard_common::smol_str::SmolStr::new_static("content"),
214                            ::jacquard_lexicon::lexicon::LexObjectProperty::Union(::jacquard_lexicon::lexicon::LexRefUnion {
215                                description: None,
216                                refs: vec![
217                                    ::jacquard_common::CowStr::new_static("pub.leaflet.blocks.text"),
218                                    ::jacquard_common::CowStr::new_static("pub.leaflet.blocks.header"),
219                                    ::jacquard_common::CowStr::new_static("pub.leaflet.blocks.image")
220                                ],
221                                closed: None,
222                            }),
223                        );
224                        map
225                    },
226                }),
227            );
228            map.insert(
229                ::jacquard_common::smol_str::SmolStr::new_static("main"),
230                ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
231                    description: None,
232                    required: Some(
233                        vec![
234                            ::jacquard_common::smol_str::SmolStr::new_static("children")
235                        ],
236                    ),
237                    nullable: None,
238                    properties: {
239                        #[allow(unused_mut)]
240                        let mut map = ::std::collections::BTreeMap::new();
241                        map.insert(
242                            ::jacquard_common::smol_str::SmolStr::new_static("children"),
243                            ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
244                                description: None,
245                                items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef {
246                                    description: None,
247                                    r#ref: ::jacquard_common::CowStr::new_static("#listItem"),
248                                }),
249                                min_length: None,
250                                max_length: None,
251                            }),
252                        );
253                        map
254                    },
255                }),
256            );
257            map
258        },
259    }
260}
261
262impl<'a> ::jacquard_lexicon::schema::LexiconSchema for ListItem<'a> {
263    fn nsid() -> &'static str {
264        "pub.leaflet.blocks.unorderedList"
265    }
266    fn def_name() -> &'static str {
267        "listItem"
268    }
269    fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
270        lexicon_doc_pub_leaflet_blocks_unorderedList()
271    }
272    fn validate(
273        &self,
274    ) -> ::std::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
275        Ok(())
276    }
277}
278
279#[jacquard_derive::lexicon]
280#[derive(
281    serde::Serialize,
282    serde::Deserialize,
283    Debug,
284    Clone,
285    PartialEq,
286    Eq,
287    jacquard_derive::IntoStatic
288)]
289#[serde(rename_all = "camelCase")]
290pub struct UnorderedList<'a> {
291    #[serde(borrow)]
292    pub children: Vec<crate::pub_leaflet::blocks::unordered_list::ListItem<'a>>,
293}
294
295pub mod unordered_list_state {
296
297    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
298    #[allow(unused)]
299    use ::core::marker::PhantomData;
300    mod sealed {
301        pub trait Sealed {}
302    }
303    /// State trait tracking which required fields have been set
304    pub trait State: sealed::Sealed {
305        type Children;
306    }
307    /// Empty state - all required fields are unset
308    pub struct Empty(());
309    impl sealed::Sealed for Empty {}
310    impl State for Empty {
311        type Children = Unset;
312    }
313    ///State transition - sets the `children` field to Set
314    pub struct SetChildren<S: State = Empty>(PhantomData<fn() -> S>);
315    impl<S: State> sealed::Sealed for SetChildren<S> {}
316    impl<S: State> State for SetChildren<S> {
317        type Children = Set<members::children>;
318    }
319    /// Marker types for field names
320    #[allow(non_camel_case_types)]
321    pub mod members {
322        ///Marker type for the `children` field
323        pub struct children(());
324    }
325}
326
327/// Builder for constructing an instance of this type
328pub struct UnorderedListBuilder<'a, S: unordered_list_state::State> {
329    _phantom_state: ::core::marker::PhantomData<fn() -> S>,
330    __unsafe_private_named: (
331        ::core::option::Option<
332            Vec<crate::pub_leaflet::blocks::unordered_list::ListItem<'a>>,
333        >,
334    ),
335    _phantom: ::core::marker::PhantomData<&'a ()>,
336}
337
338impl<'a> UnorderedList<'a> {
339    /// Create a new builder for this type
340    pub fn new() -> UnorderedListBuilder<'a, unordered_list_state::Empty> {
341        UnorderedListBuilder::new()
342    }
343}
344
345impl<'a> UnorderedListBuilder<'a, unordered_list_state::Empty> {
346    /// Create a new builder with all fields unset
347    pub fn new() -> Self {
348        UnorderedListBuilder {
349            _phantom_state: ::core::marker::PhantomData,
350            __unsafe_private_named: (None,),
351            _phantom: ::core::marker::PhantomData,
352        }
353    }
354}
355
356impl<'a, S> UnorderedListBuilder<'a, S>
357where
358    S: unordered_list_state::State,
359    S::Children: unordered_list_state::IsUnset,
360{
361    /// Set the `children` field (required)
362    pub fn children(
363        mut self,
364        value: impl Into<Vec<crate::pub_leaflet::blocks::unordered_list::ListItem<'a>>>,
365    ) -> UnorderedListBuilder<'a, unordered_list_state::SetChildren<S>> {
366        self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
367        UnorderedListBuilder {
368            _phantom_state: ::core::marker::PhantomData,
369            __unsafe_private_named: self.__unsafe_private_named,
370            _phantom: ::core::marker::PhantomData,
371        }
372    }
373}
374
375impl<'a, S> UnorderedListBuilder<'a, S>
376where
377    S: unordered_list_state::State,
378    S::Children: unordered_list_state::IsSet,
379{
380    /// Build the final struct
381    pub fn build(self) -> UnorderedList<'a> {
382        UnorderedList {
383            children: self.__unsafe_private_named.0.unwrap(),
384            extra_data: Default::default(),
385        }
386    }
387    /// Build the final struct with custom extra_data
388    pub fn build_with_data(
389        self,
390        extra_data: std::collections::BTreeMap<
391            jacquard_common::smol_str::SmolStr,
392            jacquard_common::types::value::Data<'a>,
393        >,
394    ) -> UnorderedList<'a> {
395        UnorderedList {
396            children: self.__unsafe_private_named.0.unwrap(),
397            extra_data: Some(extra_data),
398        }
399    }
400}
401
402impl<'a> ::jacquard_lexicon::schema::LexiconSchema for UnorderedList<'a> {
403    fn nsid() -> &'static str {
404        "pub.leaflet.blocks.unorderedList"
405    }
406    fn def_name() -> &'static str {
407        "main"
408    }
409    fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
410        lexicon_doc_pub_leaflet_blocks_unorderedList()
411    }
412    fn validate(
413        &self,
414    ) -> ::std::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
415        Ok(())
416    }
417}