Skip to main content

jacquard_api/blog_pckt/block/
task_list.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: blog.pckt.block.taskList
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13
14#[allow(unused_imports)]
15use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
16use jacquard_derive::{IntoStatic, lexicon};
17use jacquard_lexicon::lexicon::LexiconDoc;
18use jacquard_lexicon::schema::LexiconSchema;
19
20#[allow(unused_imports)]
21use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
22use serde::{Serialize, Deserialize};
23use crate::blog_pckt::block::task_item::TaskItem;
24
25#[lexicon]
26#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
27#[serde(rename_all = "camelCase")]
28pub struct TaskList<'a> {
29    ///Array of task items
30    #[serde(borrow)]
31    pub content: Vec<TaskItem<'a>>,
32}
33
34impl<'a> LexiconSchema for TaskList<'a> {
35    fn nsid() -> &'static str {
36        "blog.pckt.block.taskList"
37    }
38    fn def_name() -> &'static str {
39        "main"
40    }
41    fn lexicon_doc() -> LexiconDoc<'static> {
42        lexicon_doc_blog_pckt_block_taskList()
43    }
44    fn validate(&self) -> Result<(), ConstraintError> {
45        Ok(())
46    }
47}
48
49pub mod task_list_state {
50
51    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
52    #[allow(unused)]
53    use ::core::marker::PhantomData;
54    mod sealed {
55        pub trait Sealed {}
56    }
57    /// State trait tracking which required fields have been set
58    pub trait State: sealed::Sealed {
59        type Content;
60    }
61    /// Empty state - all required fields are unset
62    pub struct Empty(());
63    impl sealed::Sealed for Empty {}
64    impl State for Empty {
65        type Content = Unset;
66    }
67    ///State transition - sets the `content` field to Set
68    pub struct SetContent<S: State = Empty>(PhantomData<fn() -> S>);
69    impl<S: State> sealed::Sealed for SetContent<S> {}
70    impl<S: State> State for SetContent<S> {
71        type Content = Set<members::content>;
72    }
73    /// Marker types for field names
74    #[allow(non_camel_case_types)]
75    pub mod members {
76        ///Marker type for the `content` field
77        pub struct content(());
78    }
79}
80
81/// Builder for constructing an instance of this type
82pub struct TaskListBuilder<'a, S: task_list_state::State> {
83    _state: PhantomData<fn() -> S>,
84    _fields: (Option<Vec<TaskItem<'a>>>,),
85    _lifetime: PhantomData<&'a ()>,
86}
87
88impl<'a> TaskList<'a> {
89    /// Create a new builder for this type
90    pub fn new() -> TaskListBuilder<'a, task_list_state::Empty> {
91        TaskListBuilder::new()
92    }
93}
94
95impl<'a> TaskListBuilder<'a, task_list_state::Empty> {
96    /// Create a new builder with all fields unset
97    pub fn new() -> Self {
98        TaskListBuilder {
99            _state: PhantomData,
100            _fields: (None,),
101            _lifetime: PhantomData,
102        }
103    }
104}
105
106impl<'a, S> TaskListBuilder<'a, S>
107where
108    S: task_list_state::State,
109    S::Content: task_list_state::IsUnset,
110{
111    /// Set the `content` field (required)
112    pub fn content(
113        mut self,
114        value: impl Into<Vec<TaskItem<'a>>>,
115    ) -> TaskListBuilder<'a, task_list_state::SetContent<S>> {
116        self._fields.0 = Option::Some(value.into());
117        TaskListBuilder {
118            _state: PhantomData,
119            _fields: self._fields,
120            _lifetime: PhantomData,
121        }
122    }
123}
124
125impl<'a, S> TaskListBuilder<'a, S>
126where
127    S: task_list_state::State,
128    S::Content: task_list_state::IsSet,
129{
130    /// Build the final struct
131    pub fn build(self) -> TaskList<'a> {
132        TaskList {
133            content: self._fields.0.unwrap(),
134            extra_data: Default::default(),
135        }
136    }
137    /// Build the final struct with custom extra_data
138    pub fn build_with_data(
139        self,
140        extra_data: BTreeMap<
141            jacquard_common::deps::smol_str::SmolStr,
142            jacquard_common::types::value::Data<'a>,
143        >,
144    ) -> TaskList<'a> {
145        TaskList {
146            content: self._fields.0.unwrap(),
147            extra_data: Some(extra_data),
148        }
149    }
150}
151
152fn lexicon_doc_blog_pckt_block_taskList() -> LexiconDoc<'static> {
153    #[allow(unused_imports)]
154    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
155    use jacquard_lexicon::lexicon::*;
156    use alloc::collections::BTreeMap;
157    LexiconDoc {
158        lexicon: Lexicon::Lexicon1,
159        id: CowStr::new_static("blog.pckt.block.taskList"),
160        defs: {
161            let mut map = BTreeMap::new();
162            map.insert(
163                SmolStr::new_static("main"),
164                LexUserType::Object(LexObject {
165                    required: Some(vec![SmolStr::new_static("content")]),
166                    properties: {
167                        #[allow(unused_mut)]
168                        let mut map = BTreeMap::new();
169                        map.insert(
170                            SmolStr::new_static("content"),
171                            LexObjectProperty::Array(LexArray {
172                                description: Some(
173                                    CowStr::new_static("Array of task items"),
174                                ),
175                                items: LexArrayItem::Ref(LexRef {
176                                    r#ref: CowStr::new_static("blog.pckt.block.taskItem"),
177                                    ..Default::default()
178                                }),
179                                ..Default::default()
180                            }),
181                        );
182                        map
183                    },
184                    ..Default::default()
185                }),
186            );
187            map
188        },
189        ..Default::default()
190    }
191}