1#[jacquard_derive::lexicon]
10#[derive(
11 serde::Serialize,
12 serde::Deserialize,
13 Debug,
14 Clone,
15 PartialEq,
16 Eq,
17 jacquard_derive::IntoStatic
18)]
19#[serde(rename_all = "camelCase")]
20pub struct Chapter<'a> {
21 #[serde(skip_serializing_if = "std::option::Option::is_none")]
23 pub created_at: Option<jacquard_common::types::string::Datetime>,
24 #[serde(borrow)]
25 pub entry_list: Vec<crate::com_atproto::repo::strong_ref::StrongRef<'a>>,
26 #[serde(borrow)]
28 pub notebook: crate::com_atproto::repo::strong_ref::StrongRef<'a>,
29 #[serde(skip_serializing_if = "std::option::Option::is_none")]
30 #[serde(borrow)]
31 pub tags: Option<crate::sh_weaver::notebook::Tags<'a>>,
32 #[serde(skip_serializing_if = "std::option::Option::is_none")]
33 #[serde(borrow)]
34 pub title: Option<crate::sh_weaver::notebook::Title<'a>>,
35}
36
37pub mod chapter_state {
38
39 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
40 #[allow(unused)]
41 use ::core::marker::PhantomData;
42 mod sealed {
43 pub trait Sealed {}
44 }
45 pub trait State: sealed::Sealed {
47 type Notebook;
48 type Authors;
49 type EntryList;
50 }
51 pub struct Empty(());
53 impl sealed::Sealed for Empty {}
54 impl State for Empty {
55 type Notebook = Unset;
56 type Authors = Unset;
57 type EntryList = Unset;
58 }
59 pub struct SetNotebook<S: State = Empty>(PhantomData<fn() -> S>);
61 impl<S: State> sealed::Sealed for SetNotebook<S> {}
62 impl<S: State> State for SetNotebook<S> {
63 type Notebook = Set<members::notebook>;
64 type Authors = S::Authors;
65 type EntryList = S::EntryList;
66 }
67 pub struct SetAuthors<S: State = Empty>(PhantomData<fn() -> S>);
69 impl<S: State> sealed::Sealed for SetAuthors<S> {}
70 impl<S: State> State for SetAuthors<S> {
71 type Notebook = S::Notebook;
72 type Authors = Set<members::authors>;
73 type EntryList = S::EntryList;
74 }
75 pub struct SetEntryList<S: State = Empty>(PhantomData<fn() -> S>);
77 impl<S: State> sealed::Sealed for SetEntryList<S> {}
78 impl<S: State> State for SetEntryList<S> {
79 type Notebook = S::Notebook;
80 type Authors = S::Authors;
81 type EntryList = Set<members::entry_list>;
82 }
83 #[allow(non_camel_case_types)]
85 pub mod members {
86 pub struct notebook(());
88 pub struct authors(());
90 pub struct entry_list(());
92 }
93}
94
95pub struct ChapterBuilder<'a, S: chapter_state::State> {
97 _phantom_state: ::core::marker::PhantomData<fn() -> S>,
98 __unsafe_private_named: (
99 ::core::option::Option<jacquard_common::types::string::Datetime>,
100 ::core::option::Option<Vec<crate::com_atproto::repo::strong_ref::StrongRef<'a>>>,
101 ::core::option::Option<crate::com_atproto::repo::strong_ref::StrongRef<'a>>,
102 ::core::option::Option<crate::sh_weaver::notebook::Tags<'a>>,
103 ::core::option::Option<crate::sh_weaver::notebook::Title<'a>>,
104 ),
105 _phantom: ::core::marker::PhantomData<&'a ()>,
106}
107
108impl<'a> Chapter<'a> {
109 pub fn new() -> ChapterBuilder<'a, chapter_state::Empty> {
111 ChapterBuilder::new()
112 }
113}
114
115impl<'a> ChapterBuilder<'a, chapter_state::Empty> {
116 pub fn new() -> Self {
118 ChapterBuilder {
119 _phantom_state: ::core::marker::PhantomData,
120 __unsafe_private_named: (None, None, None, None, None),
121 _phantom: ::core::marker::PhantomData,
122 }
123 }
124}
125
126impl<'a, S: chapter_state::State> ChapterBuilder<'a, S> {
127 pub fn created_at(
129 mut self,
130 value: impl Into<Option<jacquard_common::types::string::Datetime>>,
131 ) -> Self {
132 self.__unsafe_private_named.0 = value.into();
133 self
134 }
135 pub fn maybe_created_at(
137 mut self,
138 value: Option<jacquard_common::types::string::Datetime>,
139 ) -> Self {
140 self.__unsafe_private_named.0 = value;
141 self
142 }
143}
144
145impl<'a, S> ChapterBuilder<'a, S>
146where
147 S: chapter_state::State,
148 S::EntryList: chapter_state::IsUnset,
149{
150 pub fn entry_list(
152 mut self,
153 value: impl Into<Vec<crate::com_atproto::repo::strong_ref::StrongRef<'a>>>,
154 ) -> ChapterBuilder<'a, chapter_state::SetEntryList<S>> {
155 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
156 ChapterBuilder {
157 _phantom_state: ::core::marker::PhantomData,
158 __unsafe_private_named: self.__unsafe_private_named,
159 _phantom: ::core::marker::PhantomData,
160 }
161 }
162}
163
164impl<'a, S> ChapterBuilder<'a, S>
165where
166 S: chapter_state::State,
167 S::Notebook: chapter_state::IsUnset,
168{
169 pub fn notebook(
171 mut self,
172 value: impl Into<crate::com_atproto::repo::strong_ref::StrongRef<'a>>,
173 ) -> ChapterBuilder<'a, chapter_state::SetNotebook<S>> {
174 self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into());
175 ChapterBuilder {
176 _phantom_state: ::core::marker::PhantomData,
177 __unsafe_private_named: self.__unsafe_private_named,
178 _phantom: ::core::marker::PhantomData,
179 }
180 }
181}
182
183impl<'a, S: chapter_state::State> ChapterBuilder<'a, S> {
184 pub fn tags(
186 mut self,
187 value: impl Into<Option<crate::sh_weaver::notebook::Tags<'a>>>,
188 ) -> Self {
189 self.__unsafe_private_named.3 = value.into();
190 self
191 }
192 pub fn maybe_tags(
194 mut self,
195 value: Option<crate::sh_weaver::notebook::Tags<'a>>,
196 ) -> Self {
197 self.__unsafe_private_named.3 = value;
198 self
199 }
200}
201
202impl<'a, S: chapter_state::State> ChapterBuilder<'a, S> {
203 pub fn title(
205 mut self,
206 value: impl Into<Option<crate::sh_weaver::notebook::Title<'a>>>,
207 ) -> Self {
208 self.__unsafe_private_named.4 = value.into();
209 self
210 }
211 pub fn maybe_title(
213 mut self,
214 value: Option<crate::sh_weaver::notebook::Title<'a>>,
215 ) -> Self {
216 self.__unsafe_private_named.4 = value;
217 self
218 }
219}
220
221impl<'a, S> ChapterBuilder<'a, S>
222where
223 S: chapter_state::State,
224 S::Notebook: chapter_state::IsSet,
225 S::Authors: chapter_state::IsSet,
226 S::EntryList: chapter_state::IsSet,
227{
228 pub fn build(self) -> Chapter<'a> {
230 Chapter {
231 created_at: self.__unsafe_private_named.0,
232 entry_list: self.__unsafe_private_named.1.unwrap(),
233 notebook: self.__unsafe_private_named.2.unwrap(),
234 tags: self.__unsafe_private_named.3,
235 title: self.__unsafe_private_named.4,
236 extra_data: Default::default(),
237 }
238 }
239 pub fn build_with_data(
241 self,
242 extra_data: std::collections::BTreeMap<
243 jacquard_common::smol_str::SmolStr,
244 jacquard_common::types::value::Data<'a>,
245 >,
246 ) -> Chapter<'a> {
247 Chapter {
248 created_at: self.__unsafe_private_named.0,
249 entry_list: self.__unsafe_private_named.1.unwrap(),
250 notebook: self.__unsafe_private_named.2.unwrap(),
251 tags: self.__unsafe_private_named.3,
252 title: self.__unsafe_private_named.4,
253 extra_data: Some(extra_data),
254 }
255 }
256}
257
258impl<'a> Chapter<'a> {
259 pub fn uri(
260 uri: impl Into<jacquard_common::CowStr<'a>>,
261 ) -> Result<
262 jacquard_common::types::uri::RecordUri<'a, ChapterRecord>,
263 jacquard_common::types::uri::UriError,
264 > {
265 jacquard_common::types::uri::RecordUri::try_from_uri(
266 jacquard_common::types::string::AtUri::new_cow(uri.into())?,
267 )
268 }
269}
270
271#[derive(
273 serde::Serialize,
274 serde::Deserialize,
275 Debug,
276 Clone,
277 PartialEq,
278 Eq,
279 jacquard_derive::IntoStatic
280)]
281#[serde(rename_all = "camelCase")]
282pub struct ChapterGetRecordOutput<'a> {
283 #[serde(skip_serializing_if = "std::option::Option::is_none")]
284 #[serde(borrow)]
285 pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>,
286 #[serde(borrow)]
287 pub uri: jacquard_common::types::string::AtUri<'a>,
288 #[serde(borrow)]
289 pub value: Chapter<'a>,
290}
291
292impl From<ChapterGetRecordOutput<'_>> for Chapter<'_> {
293 fn from(output: ChapterGetRecordOutput<'_>) -> Self {
294 use jacquard_common::IntoStatic;
295 output.value.into_static()
296 }
297}
298
299impl jacquard_common::types::collection::Collection for Chapter<'_> {
300 const NSID: &'static str = "sh.weaver.notebook.chapter";
301 type Record = ChapterRecord;
302}
303
304#[derive(Debug, serde::Serialize, serde::Deserialize)]
306pub struct ChapterRecord;
307impl jacquard_common::xrpc::XrpcResp for ChapterRecord {
308 const NSID: &'static str = "sh.weaver.notebook.chapter";
309 const ENCODING: &'static str = "application/json";
310 type Output<'de> = ChapterGetRecordOutput<'de>;
311 type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
312}
313
314impl jacquard_common::types::collection::Collection for ChapterRecord {
315 const NSID: &'static str = "sh.weaver.notebook.chapter";
316 type Record = ChapterRecord;
317}
318
319impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Chapter<'a> {
320 fn nsid() -> &'static str {
321 "sh.weaver.notebook.chapter"
322 }
323 fn def_name() -> &'static str {
324 "main"
325 }
326 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
327 lexicon_doc_sh_weaver_notebook_chapter()
328 }
329 fn validate(
330 &self,
331 ) -> ::std::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
332 Ok(())
333 }
334}
335
336fn lexicon_doc_sh_weaver_notebook_chapter() -> ::jacquard_lexicon::lexicon::LexiconDoc<
337 'static,
338> {
339 ::jacquard_lexicon::lexicon::LexiconDoc {
340 lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
341 id: ::jacquard_common::CowStr::new_static("sh.weaver.notebook.chapter"),
342 revision: None,
343 description: None,
344 defs: {
345 let mut map = ::std::collections::BTreeMap::new();
346 map.insert(
347 ::jacquard_common::smol_str::SmolStr::new_static("main"),
348 ::jacquard_lexicon::lexicon::LexUserType::Record(::jacquard_lexicon::lexicon::LexRecord {
349 description: Some(
350 ::jacquard_common::CowStr::new_static(
351 "A grouping of entries in a notebook, intended to be displayed as a single page.",
352 ),
353 ),
354 key: Some(::jacquard_common::CowStr::new_static("tid")),
355 record: ::jacquard_lexicon::lexicon::LexRecordRecord::Object(::jacquard_lexicon::lexicon::LexObject {
356 description: None,
357 required: Some(
358 vec![
359 ::jacquard_common::smol_str::SmolStr::new_static("notebook"),
360 ::jacquard_common::smol_str::SmolStr::new_static("authors"),
361 ::jacquard_common::smol_str::SmolStr::new_static("entryList")
362 ],
363 ),
364 nullable: None,
365 properties: {
366 #[allow(unused_mut)]
367 let mut map = ::std::collections::BTreeMap::new();
368 map.insert(
369 ::jacquard_common::smol_str::SmolStr::new_static(
370 "createdAt",
371 ),
372 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
373 description: Some(
374 ::jacquard_common::CowStr::new_static(
375 "Client-declared timestamp when this was originally created.",
376 ),
377 ),
378 format: Some(
379 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime,
380 ),
381 default: None,
382 min_length: None,
383 max_length: None,
384 min_graphemes: None,
385 max_graphemes: None,
386 r#enum: None,
387 r#const: None,
388 known_values: None,
389 }),
390 );
391 map.insert(
392 ::jacquard_common::smol_str::SmolStr::new_static(
393 "entryList",
394 ),
395 ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
396 description: None,
397 items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef {
398 description: None,
399 r#ref: ::jacquard_common::CowStr::new_static(
400 "com.atproto.repo.strongRef",
401 ),
402 }),
403 min_length: None,
404 max_length: None,
405 }),
406 );
407 map.insert(
408 ::jacquard_common::smol_str::SmolStr::new_static(
409 "notebook",
410 ),
411 ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
412 description: None,
413 r#ref: ::jacquard_common::CowStr::new_static(
414 "com.atproto.repo.strongRef",
415 ),
416 }),
417 );
418 map.insert(
419 ::jacquard_common::smol_str::SmolStr::new_static("tags"),
420 ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
421 description: None,
422 r#ref: ::jacquard_common::CowStr::new_static(
423 "sh.weaver.notebook.defs#tags",
424 ),
425 }),
426 );
427 map.insert(
428 ::jacquard_common::smol_str::SmolStr::new_static("title"),
429 ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
430 description: None,
431 r#ref: ::jacquard_common::CowStr::new_static(
432 "sh.weaver.notebook.defs#title",
433 ),
434 }),
435 );
436 map
437 },
438 }),
439 }),
440 );
441 map
442 },
443 }
444}