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