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