jacquard_api/blog_pckt/block/
task_list.rs1#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::{BosStr, DefaultStr, FromStaticStr};
14
15#[allow(unused_imports)]
16use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
17use jacquard_common::deps::smol_str::SmolStr;
18use jacquard_common::types::value::Data;
19use jacquard_derive::IntoStatic;
20use jacquard_lexicon::lexicon::LexiconDoc;
21use jacquard_lexicon::schema::LexiconSchema;
22
23#[allow(unused_imports)]
24use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
25use serde::{Serialize, Deserialize};
26use crate::blog_pckt::block::task_item::TaskItem;
27
28#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
29#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
30pub struct TaskList<S: BosStr = DefaultStr> {
31 pub content: Vec<TaskItem<S>>,
33 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
34 pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
35}
36
37impl<S: BosStr> LexiconSchema for TaskList<S> {
38 fn nsid() -> &'static str {
39 "blog.pckt.block.taskList"
40 }
41 fn def_name() -> &'static str {
42 "main"
43 }
44 fn lexicon_doc() -> LexiconDoc<'static> {
45 lexicon_doc_blog_pckt_block_taskList()
46 }
47 fn validate(&self) -> Result<(), ConstraintError> {
48 Ok(())
49 }
50}
51
52pub mod task_list_state {
53
54 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
55 #[allow(unused)]
56 use ::core::marker::PhantomData;
57 mod sealed {
58 pub trait Sealed {}
59 }
60 pub trait State: sealed::Sealed {
62 type Content;
63 }
64 pub struct Empty(());
66 impl sealed::Sealed for Empty {}
67 impl State for Empty {
68 type Content = Unset;
69 }
70 pub struct SetContent<St: State = Empty>(PhantomData<fn() -> St>);
72 impl<St: State> sealed::Sealed for SetContent<St> {}
73 impl<St: State> State for SetContent<St> {
74 type Content = Set<members::content>;
75 }
76 #[allow(non_camel_case_types)]
78 pub mod members {
79 pub struct content(());
81 }
82}
83
84pub struct TaskListBuilder<St: task_list_state::State, S: BosStr = DefaultStr> {
86 _state: PhantomData<fn() -> St>,
87 _fields: (Option<Vec<TaskItem<S>>>,),
88 _type: PhantomData<fn() -> S>,
89}
90
91impl TaskList<DefaultStr> {
92 pub fn new() -> TaskListBuilder<task_list_state::Empty, DefaultStr> {
94 TaskListBuilder::new()
95 }
96}
97
98impl<S: BosStr> TaskList<S> {
99 pub fn builder() -> TaskListBuilder<task_list_state::Empty, S> {
101 TaskListBuilder::builder()
102 }
103}
104
105impl TaskListBuilder<task_list_state::Empty, DefaultStr> {
106 pub fn new() -> Self {
108 TaskListBuilder {
109 _state: PhantomData,
110 _fields: (None,),
111 _type: PhantomData,
112 }
113 }
114}
115
116impl<S: BosStr> TaskListBuilder<task_list_state::Empty, S> {
117 pub fn builder() -> Self {
119 TaskListBuilder {
120 _state: PhantomData,
121 _fields: (None,),
122 _type: PhantomData,
123 }
124 }
125}
126
127impl<St, S: BosStr> TaskListBuilder<St, S>
128where
129 St: task_list_state::State,
130 St::Content: task_list_state::IsUnset,
131{
132 pub fn content(
134 mut self,
135 value: impl Into<Vec<TaskItem<S>>>,
136 ) -> TaskListBuilder<task_list_state::SetContent<St>, S> {
137 self._fields.0 = Option::Some(value.into());
138 TaskListBuilder {
139 _state: PhantomData,
140 _fields: self._fields,
141 _type: PhantomData,
142 }
143 }
144}
145
146impl<St, S: BosStr> TaskListBuilder<St, S>
147where
148 St: task_list_state::State,
149 St::Content: task_list_state::IsSet,
150{
151 pub fn build(self) -> TaskList<S> {
153 TaskList {
154 content: self._fields.0.unwrap(),
155 extra_data: Default::default(),
156 }
157 }
158 pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> TaskList<S> {
160 TaskList {
161 content: self._fields.0.unwrap(),
162 extra_data: Some(extra_data),
163 }
164 }
165}
166
167fn lexicon_doc_blog_pckt_block_taskList() -> LexiconDoc<'static> {
168 #[allow(unused_imports)]
169 use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
170 use jacquard_lexicon::lexicon::*;
171 use alloc::collections::BTreeMap;
172 LexiconDoc {
173 lexicon: Lexicon::Lexicon1,
174 id: CowStr::new_static("blog.pckt.block.taskList"),
175 defs: {
176 let mut map = BTreeMap::new();
177 map.insert(
178 SmolStr::new_static("main"),
179 LexUserType::Object(LexObject {
180 required: Some(vec![SmolStr::new_static("content")]),
181 properties: {
182 #[allow(unused_mut)]
183 let mut map = BTreeMap::new();
184 map.insert(
185 SmolStr::new_static("content"),
186 LexObjectProperty::Array(LexArray {
187 description: Some(
188 CowStr::new_static("Array of task items"),
189 ),
190 items: LexArrayItem::Ref(LexRef {
191 r#ref: CowStr::new_static("blog.pckt.block.taskItem"),
192 ..Default::default()
193 }),
194 ..Default::default()
195 }),
196 );
197 map
198 },
199 ..Default::default()
200 }),
201 );
202 map
203 },
204 ..Default::default()
205 }
206}