// @generated by jacquard-lexicon. DO NOT EDIT. // // Lexicon: sh.weaver.notebook.chapter // // This file was automatically generated from Lexicon schemas. // Any manual changes will be overwritten on the next regeneration. /// A grouping of entries in a notebook. #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct Chapter<'a> { #[serde(borrow)] pub authors: Vec>, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub content_warnings: std::option::Option< crate::sh_weaver::notebook::ContentWarnings<'a>, >, /// Client-declared timestamp when this was originally created. #[serde(skip_serializing_if = "std::option::Option::is_none")] pub created_at: std::option::Option, #[serde(borrow)] pub entry_list: Vec>, /// The notebook this chapter belongs to. #[serde(borrow)] pub notebook: crate::com_atproto::repo::strong_ref::StrongRef<'a>, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub rating: std::option::Option>, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub tags: std::option::Option>, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub title: std::option::Option>, } pub mod chapter_state { pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; #[allow(unused)] use ::core::marker::PhantomData; mod sealed { pub trait Sealed {} } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { type Notebook; type Authors; type EntryList; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Notebook = Unset; type Authors = Unset; type EntryList = Unset; } ///State transition - sets the `notebook` field to Set pub struct SetNotebook(PhantomData S>); impl sealed::Sealed for SetNotebook {} impl State for SetNotebook { type Notebook = Set; type Authors = S::Authors; type EntryList = S::EntryList; } ///State transition - sets the `authors` field to Set pub struct SetAuthors(PhantomData S>); impl sealed::Sealed for SetAuthors {} impl State for SetAuthors { type Notebook = S::Notebook; type Authors = Set; type EntryList = S::EntryList; } ///State transition - sets the `entry_list` field to Set pub struct SetEntryList(PhantomData S>); impl sealed::Sealed for SetEntryList {} impl State for SetEntryList { type Notebook = S::Notebook; type Authors = S::Authors; type EntryList = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `notebook` field pub struct notebook(()); ///Marker type for the `authors` field pub struct authors(()); ///Marker type for the `entry_list` field pub struct entry_list(()); } } /// Builder for constructing an instance of this type pub struct ChapterBuilder<'a, S: chapter_state::State> { _phantom_state: ::core::marker::PhantomData S>, __unsafe_private_named: ( ::core::option::Option>>, ::core::option::Option>, ::core::option::Option, ::core::option::Option>>, ::core::option::Option>, ::core::option::Option>, ::core::option::Option>, ::core::option::Option>, ), _phantom: ::core::marker::PhantomData<&'a ()>, } impl<'a> Chapter<'a> { /// Create a new builder for this type pub fn new() -> ChapterBuilder<'a, chapter_state::Empty> { ChapterBuilder::new() } } impl<'a> ChapterBuilder<'a, chapter_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { ChapterBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: (None, None, None, None, None, None, None, None), _phantom: ::core::marker::PhantomData, } } } impl<'a, S> ChapterBuilder<'a, S> where S: chapter_state::State, S::Authors: chapter_state::IsUnset, { /// Set the `authors` field (required) pub fn authors( mut self, value: impl Into>>, ) -> ChapterBuilder<'a, chapter_state::SetAuthors> { self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); ChapterBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S: chapter_state::State> ChapterBuilder<'a, S> { /// Set the `contentWarnings` field (optional) pub fn content_warnings( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.1 = value.into(); self } /// Set the `contentWarnings` field to an Option value (optional) pub fn maybe_content_warnings( mut self, value: Option>, ) -> Self { self.__unsafe_private_named.1 = value; self } } impl<'a, S: chapter_state::State> ChapterBuilder<'a, S> { /// Set the `createdAt` field (optional) pub fn created_at( mut self, value: impl Into>, ) -> Self { self.__unsafe_private_named.2 = value.into(); self } /// Set the `createdAt` field to an Option value (optional) pub fn maybe_created_at( mut self, value: Option, ) -> Self { self.__unsafe_private_named.2 = value; self } } impl<'a, S> ChapterBuilder<'a, S> where S: chapter_state::State, S::EntryList: chapter_state::IsUnset, { /// Set the `entryList` field (required) pub fn entry_list( mut self, value: impl Into>>, ) -> ChapterBuilder<'a, chapter_state::SetEntryList> { self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into()); ChapterBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> ChapterBuilder<'a, S> where S: chapter_state::State, S::Notebook: chapter_state::IsUnset, { /// Set the `notebook` field (required) pub fn notebook( mut self, value: impl Into>, ) -> ChapterBuilder<'a, chapter_state::SetNotebook> { self.__unsafe_private_named.4 = ::core::option::Option::Some(value.into()); ChapterBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S: chapter_state::State> ChapterBuilder<'a, S> { /// Set the `rating` field (optional) pub fn rating( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.5 = value.into(); self } /// Set the `rating` field to an Option value (optional) pub fn maybe_rating( mut self, value: Option>, ) -> Self { self.__unsafe_private_named.5 = value; self } } impl<'a, S: chapter_state::State> ChapterBuilder<'a, S> { /// Set the `tags` field (optional) pub fn tags( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.6 = value.into(); self } /// Set the `tags` field to an Option value (optional) pub fn maybe_tags( mut self, value: Option>, ) -> Self { self.__unsafe_private_named.6 = value; self } } impl<'a, S: chapter_state::State> ChapterBuilder<'a, S> { /// Set the `title` field (optional) pub fn title( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.7 = value.into(); self } /// Set the `title` field to an Option value (optional) pub fn maybe_title( mut self, value: Option>, ) -> Self { self.__unsafe_private_named.7 = value; self } } impl<'a, S> ChapterBuilder<'a, S> where S: chapter_state::State, S::Notebook: chapter_state::IsSet, S::Authors: chapter_state::IsSet, S::EntryList: chapter_state::IsSet, { /// Build the final struct pub fn build(self) -> Chapter<'a> { Chapter { authors: self.__unsafe_private_named.0.unwrap(), content_warnings: self.__unsafe_private_named.1, created_at: self.__unsafe_private_named.2, entry_list: self.__unsafe_private_named.3.unwrap(), notebook: self.__unsafe_private_named.4.unwrap(), rating: self.__unsafe_private_named.5, tags: self.__unsafe_private_named.6, title: self.__unsafe_private_named.7, extra_data: Default::default(), } } /// Build the final struct with custom extra_data pub fn build_with_data( self, extra_data: std::collections::BTreeMap< jacquard_common::smol_str::SmolStr, jacquard_common::types::value::Data<'a>, >, ) -> Chapter<'a> { Chapter { authors: self.__unsafe_private_named.0.unwrap(), content_warnings: self.__unsafe_private_named.1, created_at: self.__unsafe_private_named.2, entry_list: self.__unsafe_private_named.3.unwrap(), notebook: self.__unsafe_private_named.4.unwrap(), rating: self.__unsafe_private_named.5, tags: self.__unsafe_private_named.6, title: self.__unsafe_private_named.7, extra_data: Some(extra_data), } } } impl<'a> Chapter<'a> { pub fn uri( uri: impl Into>, ) -> Result< jacquard_common::types::uri::RecordUri<'a, ChapterRecord>, jacquard_common::types::uri::UriError, > { jacquard_common::types::uri::RecordUri::try_from_uri( jacquard_common::types::string::AtUri::new_cow(uri.into())?, ) } } /// Typed wrapper for GetRecord response with this collection's record type. #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct ChapterGetRecordOutput<'a> { #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub cid: std::option::Option>, #[serde(borrow)] pub uri: jacquard_common::types::string::AtUri<'a>, #[serde(borrow)] pub value: Chapter<'a>, } impl From> for Chapter<'_> { fn from(output: ChapterGetRecordOutput<'_>) -> Self { use jacquard_common::IntoStatic; output.value.into_static() } } impl jacquard_common::types::collection::Collection for Chapter<'_> { const NSID: &'static str = "sh.weaver.notebook.chapter"; type Record = ChapterRecord; } /// Marker type for deserializing records from this collection. #[derive(Debug, serde::Serialize, serde::Deserialize)] pub struct ChapterRecord; impl jacquard_common::xrpc::XrpcResp for ChapterRecord { const NSID: &'static str = "sh.weaver.notebook.chapter"; const ENCODING: &'static str = "application/json"; type Output<'de> = ChapterGetRecordOutput<'de>; type Err<'de> = jacquard_common::types::collection::RecordError<'de>; } impl jacquard_common::types::collection::Collection for ChapterRecord { const NSID: &'static str = "sh.weaver.notebook.chapter"; type Record = ChapterRecord; } impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Chapter<'a> { fn nsid() -> &'static str { "sh.weaver.notebook.chapter" } fn def_name() -> &'static str { "main" } fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { lexicon_doc_sh_weaver_notebook_chapter() } fn validate( &self, ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { Ok(()) } } fn lexicon_doc_sh_weaver_notebook_chapter() -> ::jacquard_lexicon::lexicon::LexiconDoc< 'static, > { ::jacquard_lexicon::lexicon::LexiconDoc { lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, id: ::jacquard_common::CowStr::new_static("sh.weaver.notebook.chapter"), revision: None, description: None, defs: { let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("main"), ::jacquard_lexicon::lexicon::LexUserType::Record(::jacquard_lexicon::lexicon::LexRecord { description: Some( ::jacquard_common::CowStr::new_static( "A grouping of entries in a notebook.", ), ), key: Some(::jacquard_common::CowStr::new_static("tid")), record: ::jacquard_lexicon::lexicon::LexRecordRecord::Object(::jacquard_lexicon::lexicon::LexObject { description: None, required: Some( vec![ ::jacquard_common::smol_str::SmolStr::new_static("notebook"), ::jacquard_common::smol_str::SmolStr::new_static("authors"), ::jacquard_common::smol_str::SmolStr::new_static("entryList") ], ), nullable: None, properties: { #[allow(unused_mut)] let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("authors"), ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray { description: None, items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef { description: None, r#ref: ::jacquard_common::CowStr::new_static( "sh.weaver.actor.defs#author", ), }), min_length: None, max_length: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "contentWarnings", ), ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { description: None, r#ref: ::jacquard_common::CowStr::new_static( "sh.weaver.notebook.defs#contentWarnings", ), }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "createdAt", ), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: Some( ::jacquard_common::CowStr::new_static( "Client-declared timestamp when this was originally created.", ), ), format: Some( ::jacquard_lexicon::lexicon::LexStringFormat::Datetime, ), default: None, min_length: None, max_length: None, min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "entryList", ), ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray { description: None, items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef { description: None, r#ref: ::jacquard_common::CowStr::new_static( "com.atproto.repo.strongRef", ), }), min_length: None, max_length: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "notebook", ), ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { description: None, r#ref: ::jacquard_common::CowStr::new_static( "com.atproto.repo.strongRef", ), }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("rating"), ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { description: None, r#ref: ::jacquard_common::CowStr::new_static( "sh.weaver.notebook.defs#contentRating", ), }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("tags"), ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { description: None, r#ref: ::jacquard_common::CowStr::new_static( "sh.weaver.notebook.defs#tags", ), }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("title"), ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { description: None, r#ref: ::jacquard_common::CowStr::new_static( "sh.weaver.notebook.defs#title", ), }), ); map }, }), }), ); map }, } }