atproto blogging
1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: sh.weaver.notebook.chapter
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8/// A grouping of entries in a notebook.
9#[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(borrow)]
22 pub authors: Vec<crate::sh_weaver::actor::Author<'a>>,
23 #[serde(skip_serializing_if = "std::option::Option::is_none")]
24 #[serde(borrow)]
25 pub content_warnings: std::option::Option<
26 crate::sh_weaver::notebook::ContentWarnings<'a>,
27 >,
28 /// Client-declared timestamp when this was originally created.
29 #[serde(skip_serializing_if = "std::option::Option::is_none")]
30 pub created_at: std::option::Option<jacquard_common::types::string::Datetime>,
31 #[serde(borrow)]
32 pub entry_list: Vec<crate::com_atproto::repo::strong_ref::StrongRef<'a>>,
33 /// The notebook this chapter belongs to.
34 #[serde(borrow)]
35 pub notebook: crate::com_atproto::repo::strong_ref::StrongRef<'a>,
36 #[serde(skip_serializing_if = "std::option::Option::is_none")]
37 #[serde(borrow)]
38 pub rating: std::option::Option<crate::sh_weaver::notebook::ContentRating<'a>>,
39 #[serde(skip_serializing_if = "std::option::Option::is_none")]
40 #[serde(borrow)]
41 pub tags: std::option::Option<crate::sh_weaver::notebook::Tags<'a>>,
42 #[serde(skip_serializing_if = "std::option::Option::is_none")]
43 #[serde(borrow)]
44 pub title: std::option::Option<crate::sh_weaver::notebook::Title<'a>>,
45}
46
47pub mod chapter_state {
48
49 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
50 #[allow(unused)]
51 use ::core::marker::PhantomData;
52 mod sealed {
53 pub trait Sealed {}
54 }
55 /// State trait tracking which required fields have been set
56 pub trait State: sealed::Sealed {
57 type Notebook;
58 type Authors;
59 type EntryList;
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 Notebook = Unset;
66 type Authors = Unset;
67 type EntryList = Unset;
68 }
69 ///State transition - sets the `notebook` field to Set
70 pub struct SetNotebook<S: State = Empty>(PhantomData<fn() -> S>);
71 impl<S: State> sealed::Sealed for SetNotebook<S> {}
72 impl<S: State> State for SetNotebook<S> {
73 type Notebook = Set<members::notebook>;
74 type Authors = S::Authors;
75 type EntryList = S::EntryList;
76 }
77 ///State transition - sets the `authors` field to Set
78 pub struct SetAuthors<S: State = Empty>(PhantomData<fn() -> S>);
79 impl<S: State> sealed::Sealed for SetAuthors<S> {}
80 impl<S: State> State for SetAuthors<S> {
81 type Notebook = S::Notebook;
82 type Authors = Set<members::authors>;
83 type EntryList = S::EntryList;
84 }
85 ///State transition - sets the `entry_list` field to Set
86 pub struct SetEntryList<S: State = Empty>(PhantomData<fn() -> S>);
87 impl<S: State> sealed::Sealed for SetEntryList<S> {}
88 impl<S: State> State for SetEntryList<S> {
89 type Notebook = S::Notebook;
90 type Authors = S::Authors;
91 type EntryList = Set<members::entry_list>;
92 }
93 /// Marker types for field names
94 #[allow(non_camel_case_types)]
95 pub mod members {
96 ///Marker type for the `notebook` field
97 pub struct notebook(());
98 ///Marker type for the `authors` field
99 pub struct authors(());
100 ///Marker type for the `entry_list` field
101 pub struct entry_list(());
102 }
103}
104
105/// Builder for constructing an instance of this type
106pub struct ChapterBuilder<'a, S: chapter_state::State> {
107 _phantom_state: ::core::marker::PhantomData<fn() -> S>,
108 __unsafe_private_named: (
109 ::core::option::Option<Vec<crate::sh_weaver::actor::Author<'a>>>,
110 ::core::option::Option<crate::sh_weaver::notebook::ContentWarnings<'a>>,
111 ::core::option::Option<jacquard_common::types::string::Datetime>,
112 ::core::option::Option<Vec<crate::com_atproto::repo::strong_ref::StrongRef<'a>>>,
113 ::core::option::Option<crate::com_atproto::repo::strong_ref::StrongRef<'a>>,
114 ::core::option::Option<crate::sh_weaver::notebook::ContentRating<'a>>,
115 ::core::option::Option<crate::sh_weaver::notebook::Tags<'a>>,
116 ::core::option::Option<crate::sh_weaver::notebook::Title<'a>>,
117 ),
118 _phantom: ::core::marker::PhantomData<&'a ()>,
119}
120
121impl<'a> Chapter<'a> {
122 /// Create a new builder for this type
123 pub fn new() -> ChapterBuilder<'a, chapter_state::Empty> {
124 ChapterBuilder::new()
125 }
126}
127
128impl<'a> ChapterBuilder<'a, chapter_state::Empty> {
129 /// Create a new builder with all fields unset
130 pub fn new() -> Self {
131 ChapterBuilder {
132 _phantom_state: ::core::marker::PhantomData,
133 __unsafe_private_named: (None, None, None, None, None, None, None, None),
134 _phantom: ::core::marker::PhantomData,
135 }
136 }
137}
138
139impl<'a, S> ChapterBuilder<'a, S>
140where
141 S: chapter_state::State,
142 S::Authors: chapter_state::IsUnset,
143{
144 /// Set the `authors` field (required)
145 pub fn authors(
146 mut self,
147 value: impl Into<Vec<crate::sh_weaver::actor::Author<'a>>>,
148 ) -> ChapterBuilder<'a, chapter_state::SetAuthors<S>> {
149 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
150 ChapterBuilder {
151 _phantom_state: ::core::marker::PhantomData,
152 __unsafe_private_named: self.__unsafe_private_named,
153 _phantom: ::core::marker::PhantomData,
154 }
155 }
156}
157
158impl<'a, S: chapter_state::State> ChapterBuilder<'a, S> {
159 /// Set the `contentWarnings` field (optional)
160 pub fn content_warnings(
161 mut self,
162 value: impl Into<Option<crate::sh_weaver::notebook::ContentWarnings<'a>>>,
163 ) -> Self {
164 self.__unsafe_private_named.1 = value.into();
165 self
166 }
167 /// Set the `contentWarnings` field to an Option value (optional)
168 pub fn maybe_content_warnings(
169 mut self,
170 value: Option<crate::sh_weaver::notebook::ContentWarnings<'a>>,
171 ) -> Self {
172 self.__unsafe_private_named.1 = value;
173 self
174 }
175}
176
177impl<'a, S: chapter_state::State> ChapterBuilder<'a, S> {
178 /// Set the `createdAt` field (optional)
179 pub fn created_at(
180 mut self,
181 value: impl Into<Option<jacquard_common::types::string::Datetime>>,
182 ) -> Self {
183 self.__unsafe_private_named.2 = value.into();
184 self
185 }
186 /// Set the `createdAt` field to an Option value (optional)
187 pub fn maybe_created_at(
188 mut self,
189 value: Option<jacquard_common::types::string::Datetime>,
190 ) -> Self {
191 self.__unsafe_private_named.2 = value;
192 self
193 }
194}
195
196impl<'a, S> ChapterBuilder<'a, S>
197where
198 S: chapter_state::State,
199 S::EntryList: chapter_state::IsUnset,
200{
201 /// Set the `entryList` field (required)
202 pub fn entry_list(
203 mut self,
204 value: impl Into<Vec<crate::com_atproto::repo::strong_ref::StrongRef<'a>>>,
205 ) -> ChapterBuilder<'a, chapter_state::SetEntryList<S>> {
206 self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into());
207 ChapterBuilder {
208 _phantom_state: ::core::marker::PhantomData,
209 __unsafe_private_named: self.__unsafe_private_named,
210 _phantom: ::core::marker::PhantomData,
211 }
212 }
213}
214
215impl<'a, S> ChapterBuilder<'a, S>
216where
217 S: chapter_state::State,
218 S::Notebook: chapter_state::IsUnset,
219{
220 /// Set the `notebook` field (required)
221 pub fn notebook(
222 mut self,
223 value: impl Into<crate::com_atproto::repo::strong_ref::StrongRef<'a>>,
224 ) -> ChapterBuilder<'a, chapter_state::SetNotebook<S>> {
225 self.__unsafe_private_named.4 = ::core::option::Option::Some(value.into());
226 ChapterBuilder {
227 _phantom_state: ::core::marker::PhantomData,
228 __unsafe_private_named: self.__unsafe_private_named,
229 _phantom: ::core::marker::PhantomData,
230 }
231 }
232}
233
234impl<'a, S: chapter_state::State> ChapterBuilder<'a, S> {
235 /// Set the `rating` field (optional)
236 pub fn rating(
237 mut self,
238 value: impl Into<Option<crate::sh_weaver::notebook::ContentRating<'a>>>,
239 ) -> Self {
240 self.__unsafe_private_named.5 = value.into();
241 self
242 }
243 /// Set the `rating` field to an Option value (optional)
244 pub fn maybe_rating(
245 mut self,
246 value: Option<crate::sh_weaver::notebook::ContentRating<'a>>,
247 ) -> Self {
248 self.__unsafe_private_named.5 = value;
249 self
250 }
251}
252
253impl<'a, S: chapter_state::State> ChapterBuilder<'a, S> {
254 /// Set the `tags` field (optional)
255 pub fn tags(
256 mut self,
257 value: impl Into<Option<crate::sh_weaver::notebook::Tags<'a>>>,
258 ) -> Self {
259 self.__unsafe_private_named.6 = value.into();
260 self
261 }
262 /// Set the `tags` field to an Option value (optional)
263 pub fn maybe_tags(
264 mut self,
265 value: Option<crate::sh_weaver::notebook::Tags<'a>>,
266 ) -> Self {
267 self.__unsafe_private_named.6 = value;
268 self
269 }
270}
271
272impl<'a, S: chapter_state::State> ChapterBuilder<'a, S> {
273 /// Set the `title` field (optional)
274 pub fn title(
275 mut self,
276 value: impl Into<Option<crate::sh_weaver::notebook::Title<'a>>>,
277 ) -> Self {
278 self.__unsafe_private_named.7 = value.into();
279 self
280 }
281 /// Set the `title` field to an Option value (optional)
282 pub fn maybe_title(
283 mut self,
284 value: Option<crate::sh_weaver::notebook::Title<'a>>,
285 ) -> Self {
286 self.__unsafe_private_named.7 = value;
287 self
288 }
289}
290
291impl<'a, S> ChapterBuilder<'a, S>
292where
293 S: chapter_state::State,
294 S::Notebook: chapter_state::IsSet,
295 S::Authors: chapter_state::IsSet,
296 S::EntryList: chapter_state::IsSet,
297{
298 /// Build the final struct
299 pub fn build(self) -> Chapter<'a> {
300 Chapter {
301 authors: self.__unsafe_private_named.0.unwrap(),
302 content_warnings: self.__unsafe_private_named.1,
303 created_at: self.__unsafe_private_named.2,
304 entry_list: self.__unsafe_private_named.3.unwrap(),
305 notebook: self.__unsafe_private_named.4.unwrap(),
306 rating: self.__unsafe_private_named.5,
307 tags: self.__unsafe_private_named.6,
308 title: self.__unsafe_private_named.7,
309 extra_data: Default::default(),
310 }
311 }
312 /// Build the final struct with custom extra_data
313 pub fn build_with_data(
314 self,
315 extra_data: std::collections::BTreeMap<
316 jacquard_common::smol_str::SmolStr,
317 jacquard_common::types::value::Data<'a>,
318 >,
319 ) -> Chapter<'a> {
320 Chapter {
321 authors: self.__unsafe_private_named.0.unwrap(),
322 content_warnings: self.__unsafe_private_named.1,
323 created_at: self.__unsafe_private_named.2,
324 entry_list: self.__unsafe_private_named.3.unwrap(),
325 notebook: self.__unsafe_private_named.4.unwrap(),
326 rating: self.__unsafe_private_named.5,
327 tags: self.__unsafe_private_named.6,
328 title: self.__unsafe_private_named.7,
329 extra_data: Some(extra_data),
330 }
331 }
332}
333
334impl<'a> Chapter<'a> {
335 pub fn uri(
336 uri: impl Into<jacquard_common::CowStr<'a>>,
337 ) -> Result<
338 jacquard_common::types::uri::RecordUri<'a, ChapterRecord>,
339 jacquard_common::types::uri::UriError,
340 > {
341 jacquard_common::types::uri::RecordUri::try_from_uri(
342 jacquard_common::types::string::AtUri::new_cow(uri.into())?,
343 )
344 }
345}
346
347/// Typed wrapper for GetRecord response with this collection's record type.
348#[derive(
349 serde::Serialize,
350 serde::Deserialize,
351 Debug,
352 Clone,
353 PartialEq,
354 Eq,
355 jacquard_derive::IntoStatic
356)]
357#[serde(rename_all = "camelCase")]
358pub struct ChapterGetRecordOutput<'a> {
359 #[serde(skip_serializing_if = "std::option::Option::is_none")]
360 #[serde(borrow)]
361 pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>,
362 #[serde(borrow)]
363 pub uri: jacquard_common::types::string::AtUri<'a>,
364 #[serde(borrow)]
365 pub value: Chapter<'a>,
366}
367
368impl From<ChapterGetRecordOutput<'_>> for Chapter<'_> {
369 fn from(output: ChapterGetRecordOutput<'_>) -> Self {
370 use jacquard_common::IntoStatic;
371 output.value.into_static()
372 }
373}
374
375impl jacquard_common::types::collection::Collection for Chapter<'_> {
376 const NSID: &'static str = "sh.weaver.notebook.chapter";
377 type Record = ChapterRecord;
378}
379
380/// Marker type for deserializing records from this collection.
381#[derive(Debug, serde::Serialize, serde::Deserialize)]
382pub struct ChapterRecord;
383impl jacquard_common::xrpc::XrpcResp for ChapterRecord {
384 const NSID: &'static str = "sh.weaver.notebook.chapter";
385 const ENCODING: &'static str = "application/json";
386 type Output<'de> = ChapterGetRecordOutput<'de>;
387 type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
388}
389
390impl jacquard_common::types::collection::Collection for ChapterRecord {
391 const NSID: &'static str = "sh.weaver.notebook.chapter";
392 type Record = ChapterRecord;
393}
394
395impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Chapter<'a> {
396 fn nsid() -> &'static str {
397 "sh.weaver.notebook.chapter"
398 }
399 fn def_name() -> &'static str {
400 "main"
401 }
402 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
403 lexicon_doc_sh_weaver_notebook_chapter()
404 }
405 fn validate(
406 &self,
407 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
408 Ok(())
409 }
410}
411
412fn lexicon_doc_sh_weaver_notebook_chapter() -> ::jacquard_lexicon::lexicon::LexiconDoc<
413 'static,
414> {
415 ::jacquard_lexicon::lexicon::LexiconDoc {
416 lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
417 id: ::jacquard_common::CowStr::new_static("sh.weaver.notebook.chapter"),
418 revision: None,
419 description: None,
420 defs: {
421 let mut map = ::alloc::collections::BTreeMap::new();
422 map.insert(
423 ::jacquard_common::smol_str::SmolStr::new_static("main"),
424 ::jacquard_lexicon::lexicon::LexUserType::Record(::jacquard_lexicon::lexicon::LexRecord {
425 description: Some(
426 ::jacquard_common::CowStr::new_static(
427 "A grouping of entries in a notebook.",
428 ),
429 ),
430 key: Some(::jacquard_common::CowStr::new_static("tid")),
431 record: ::jacquard_lexicon::lexicon::LexRecordRecord::Object(::jacquard_lexicon::lexicon::LexObject {
432 description: None,
433 required: Some(
434 vec![
435 ::jacquard_common::smol_str::SmolStr::new_static("notebook"),
436 ::jacquard_common::smol_str::SmolStr::new_static("authors"),
437 ::jacquard_common::smol_str::SmolStr::new_static("entryList")
438 ],
439 ),
440 nullable: None,
441 properties: {
442 #[allow(unused_mut)]
443 let mut map = ::alloc::collections::BTreeMap::new();
444 map.insert(
445 ::jacquard_common::smol_str::SmolStr::new_static("authors"),
446 ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
447 description: None,
448 items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef {
449 description: None,
450 r#ref: ::jacquard_common::CowStr::new_static(
451 "sh.weaver.actor.defs#author",
452 ),
453 }),
454 min_length: None,
455 max_length: None,
456 }),
457 );
458 map.insert(
459 ::jacquard_common::smol_str::SmolStr::new_static(
460 "contentWarnings",
461 ),
462 ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
463 description: None,
464 r#ref: ::jacquard_common::CowStr::new_static(
465 "sh.weaver.notebook.defs#contentWarnings",
466 ),
467 }),
468 );
469 map.insert(
470 ::jacquard_common::smol_str::SmolStr::new_static(
471 "createdAt",
472 ),
473 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
474 description: Some(
475 ::jacquard_common::CowStr::new_static(
476 "Client-declared timestamp when this was originally created.",
477 ),
478 ),
479 format: Some(
480 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime,
481 ),
482 default: None,
483 min_length: None,
484 max_length: None,
485 min_graphemes: None,
486 max_graphemes: None,
487 r#enum: None,
488 r#const: None,
489 known_values: None,
490 }),
491 );
492 map.insert(
493 ::jacquard_common::smol_str::SmolStr::new_static(
494 "entryList",
495 ),
496 ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
497 description: None,
498 items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef {
499 description: None,
500 r#ref: ::jacquard_common::CowStr::new_static(
501 "com.atproto.repo.strongRef",
502 ),
503 }),
504 min_length: None,
505 max_length: None,
506 }),
507 );
508 map.insert(
509 ::jacquard_common::smol_str::SmolStr::new_static(
510 "notebook",
511 ),
512 ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
513 description: None,
514 r#ref: ::jacquard_common::CowStr::new_static(
515 "com.atproto.repo.strongRef",
516 ),
517 }),
518 );
519 map.insert(
520 ::jacquard_common::smol_str::SmolStr::new_static("rating"),
521 ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
522 description: None,
523 r#ref: ::jacquard_common::CowStr::new_static(
524 "sh.weaver.notebook.defs#contentRating",
525 ),
526 }),
527 );
528 map.insert(
529 ::jacquard_common::smol_str::SmolStr::new_static("tags"),
530 ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
531 description: None,
532 r#ref: ::jacquard_common::CowStr::new_static(
533 "sh.weaver.notebook.defs#tags",
534 ),
535 }),
536 );
537 map.insert(
538 ::jacquard_common::smol_str::SmolStr::new_static("title"),
539 ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
540 description: None,
541 r#ref: ::jacquard_common::CowStr::new_static(
542 "sh.weaver.notebook.defs#title",
543 ),
544 }),
545 );
546 map
547 },
548 }),
549 }),
550 );
551 map
552 },
553 }
554}