// @generated by jacquard-lexicon. DO NOT EDIT. // // Lexicon: sh.weaver.notebook.entry // // This file was automatically generated from Lexicon schemas. // Any manual changes will be overwritten on the next regeneration. /// A notebook entry #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct Entry<'a> { #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub authors: std::option::Option>>, /// The content of the notebook entry. This should be some flavor of Markdown. #[serde(borrow)] pub content: jacquard_common::CowStr<'a>, #[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. pub created_at: jacquard_common::types::string::Datetime, /// The set of images and records, if any, embedded in the notebook entry. #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub embeds: std::option::Option>, #[serde(borrow)] pub path: crate::sh_weaver::notebook::Path<'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(borrow)] pub title: crate::sh_weaver::notebook::Title<'a>, /// Client-declared timestamp of last modification. Used for canonicality tiebreaking in multi-author scenarios. #[serde(skip_serializing_if = "std::option::Option::is_none")] pub updated_at: std::option::Option, } pub mod entry_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 Content; type CreatedAt; type Title; type Path; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Content = Unset; type CreatedAt = Unset; type Title = Unset; type Path = Unset; } ///State transition - sets the `content` field to Set pub struct SetContent(PhantomData S>); impl sealed::Sealed for SetContent {} impl State for SetContent { type Content = Set; type CreatedAt = S::CreatedAt; type Title = S::Title; type Path = S::Path; } ///State transition - sets the `created_at` field to Set pub struct SetCreatedAt(PhantomData S>); impl sealed::Sealed for SetCreatedAt {} impl State for SetCreatedAt { type Content = S::Content; type CreatedAt = Set; type Title = S::Title; type Path = S::Path; } ///State transition - sets the `title` field to Set pub struct SetTitle(PhantomData S>); impl sealed::Sealed for SetTitle {} impl State for SetTitle { type Content = S::Content; type CreatedAt = S::CreatedAt; type Title = Set; type Path = S::Path; } ///State transition - sets the `path` field to Set pub struct SetPath(PhantomData S>); impl sealed::Sealed for SetPath {} impl State for SetPath { type Content = S::Content; type CreatedAt = S::CreatedAt; type Title = S::Title; type Path = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `content` field pub struct content(()); ///Marker type for the `created_at` field pub struct created_at(()); ///Marker type for the `title` field pub struct title(()); ///Marker type for the `path` field pub struct path(()); } } /// Builder for constructing an instance of this type pub struct EntryBuilder<'a, S: entry_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>, ::core::option::Option>, ::core::option::Option, ), _phantom: ::core::marker::PhantomData<&'a ()>, } impl<'a> Entry<'a> { /// Create a new builder for this type pub fn new() -> EntryBuilder<'a, entry_state::Empty> { EntryBuilder::new() } } impl<'a> EntryBuilder<'a, entry_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { EntryBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: ( None, None, None, None, None, None, None, None, None, None, ), _phantom: ::core::marker::PhantomData, } } } impl<'a, S: entry_state::State> EntryBuilder<'a, S> { /// Set the `authors` field (optional) pub fn authors( mut self, value: impl Into>>>, ) -> Self { self.__unsafe_private_named.0 = value.into(); self } /// Set the `authors` field to an Option value (optional) pub fn maybe_authors( mut self, value: Option>>, ) -> Self { self.__unsafe_private_named.0 = value; self } } impl<'a, S> EntryBuilder<'a, S> where S: entry_state::State, S::Content: entry_state::IsUnset, { /// Set the `content` field (required) pub fn content( mut self, value: impl Into>, ) -> EntryBuilder<'a, entry_state::SetContent> { self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); EntryBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S: entry_state::State> EntryBuilder<'a, S> { /// Set the `contentWarnings` field (optional) pub fn content_warnings( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.2 = 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.2 = value; self } } impl<'a, S> EntryBuilder<'a, S> where S: entry_state::State, S::CreatedAt: entry_state::IsUnset, { /// Set the `createdAt` field (required) pub fn created_at( mut self, value: impl Into, ) -> EntryBuilder<'a, entry_state::SetCreatedAt> { self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into()); EntryBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S: entry_state::State> EntryBuilder<'a, S> { /// Set the `embeds` field (optional) pub fn embeds(mut self, value: impl Into>>) -> Self { self.__unsafe_private_named.4 = value.into(); self } /// Set the `embeds` field to an Option value (optional) pub fn maybe_embeds(mut self, value: Option>) -> Self { self.__unsafe_private_named.4 = value; self } } impl<'a, S> EntryBuilder<'a, S> where S: entry_state::State, S::Path: entry_state::IsUnset, { /// Set the `path` field (required) pub fn path( mut self, value: impl Into>, ) -> EntryBuilder<'a, entry_state::SetPath> { self.__unsafe_private_named.5 = ::core::option::Option::Some(value.into()); EntryBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S: entry_state::State> EntryBuilder<'a, S> { /// Set the `rating` field (optional) pub fn rating( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.6 = 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.6 = value; self } } impl<'a, S: entry_state::State> EntryBuilder<'a, S> { /// Set the `tags` field (optional) pub fn tags( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.7 = 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.7 = value; self } } impl<'a, S> EntryBuilder<'a, S> where S: entry_state::State, S::Title: entry_state::IsUnset, { /// Set the `title` field (required) pub fn title( mut self, value: impl Into>, ) -> EntryBuilder<'a, entry_state::SetTitle> { self.__unsafe_private_named.8 = ::core::option::Option::Some(value.into()); EntryBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S: entry_state::State> EntryBuilder<'a, S> { /// Set the `updatedAt` field (optional) pub fn updated_at( mut self, value: impl Into>, ) -> Self { self.__unsafe_private_named.9 = value.into(); self } /// Set the `updatedAt` field to an Option value (optional) pub fn maybe_updated_at( mut self, value: Option, ) -> Self { self.__unsafe_private_named.9 = value; self } } impl<'a, S> EntryBuilder<'a, S> where S: entry_state::State, S::Content: entry_state::IsSet, S::CreatedAt: entry_state::IsSet, S::Title: entry_state::IsSet, S::Path: entry_state::IsSet, { /// Build the final struct pub fn build(self) -> Entry<'a> { Entry { authors: self.__unsafe_private_named.0, content: self.__unsafe_private_named.1.unwrap(), content_warnings: self.__unsafe_private_named.2, created_at: self.__unsafe_private_named.3.unwrap(), embeds: self.__unsafe_private_named.4, path: self.__unsafe_private_named.5.unwrap(), rating: self.__unsafe_private_named.6, tags: self.__unsafe_private_named.7, title: self.__unsafe_private_named.8.unwrap(), updated_at: self.__unsafe_private_named.9, 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>, >, ) -> Entry<'a> { Entry { authors: self.__unsafe_private_named.0, content: self.__unsafe_private_named.1.unwrap(), content_warnings: self.__unsafe_private_named.2, created_at: self.__unsafe_private_named.3.unwrap(), embeds: self.__unsafe_private_named.4, path: self.__unsafe_private_named.5.unwrap(), rating: self.__unsafe_private_named.6, tags: self.__unsafe_private_named.7, title: self.__unsafe_private_named.8.unwrap(), updated_at: self.__unsafe_private_named.9, extra_data: Some(extra_data), } } } impl<'a> Entry<'a> { pub fn uri( uri: impl Into>, ) -> Result< jacquard_common::types::uri::RecordUri<'a, EntryRecord>, jacquard_common::types::uri::UriError, > { jacquard_common::types::uri::RecordUri::try_from_uri( jacquard_common::types::string::AtUri::new_cow(uri.into())?, ) } } /// The set of images and records, if any, embedded in the notebook entry. #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic, Default )] #[serde(rename_all = "camelCase")] pub struct EntryEmbeds<'a> { #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub externals: std::option::Option>, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub images: std::option::Option>, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub records: std::option::Option>, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub records_with_media: std::option::Option< Vec>, >, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub videos: std::option::Option>, } fn lexicon_doc_sh_weaver_notebook_entry() -> ::jacquard_lexicon::lexicon::LexiconDoc< 'static, > { ::jacquard_lexicon::lexicon::LexiconDoc { lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, id: ::jacquard_common::CowStr::new_static("sh.weaver.notebook.entry"), 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 notebook entry"), ), 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("content"), ::jacquard_common::smol_str::SmolStr::new_static("title"), ::jacquard_common::smol_str::SmolStr::new_static("path"), ::jacquard_common::smol_str::SmolStr::new_static("createdAt") ], ), 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("content"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: Some( ::jacquard_common::CowStr::new_static( "The content of the notebook entry. This should be some flavor of Markdown.", ), ), format: None, 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( "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("embeds"), ::jacquard_lexicon::lexicon::LexObjectProperty::Object(::jacquard_lexicon::lexicon::LexObject { description: Some( ::jacquard_common::CowStr::new_static( "The set of images and records, if any, embedded in the notebook entry.", ), ), required: None, nullable: None, properties: { #[allow(unused_mut)] let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "externals", ), ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { description: None, r#ref: ::jacquard_common::CowStr::new_static( "sh.weaver.embed.external", ), }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("images"), ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { description: None, r#ref: ::jacquard_common::CowStr::new_static( "sh.weaver.embed.images", ), }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("records"), ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { description: None, r#ref: ::jacquard_common::CowStr::new_static( "sh.weaver.embed.records", ), }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "recordsWithMedia", ), ::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.embed.recordWithMedia", ), }), min_length: None, max_length: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("videos"), ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { description: None, r#ref: ::jacquard_common::CowStr::new_static( "sh.weaver.embed.video", ), }), ); map }, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("path"), ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { description: None, r#ref: ::jacquard_common::CowStr::new_static( "sh.weaver.notebook.defs#path", ), }), ); 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.insert( ::jacquard_common::smol_str::SmolStr::new_static( "updatedAt", ), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: Some( ::jacquard_common::CowStr::new_static( "Client-declared timestamp of last modification. Used for canonicality tiebreaking in multi-author scenarios.", ), ), 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 }, }), }), ); map }, } } impl<'a> ::jacquard_lexicon::schema::LexiconSchema for EntryEmbeds<'a> { fn nsid() -> &'static str { "sh.weaver.notebook.entry" } fn def_name() -> &'static str { "EntryEmbeds" } fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { lexicon_doc_sh_weaver_notebook_entry() } fn validate( &self, ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { Ok(()) } } /// 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 EntryGetRecordOutput<'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: Entry<'a>, } impl From> for Entry<'_> { fn from(output: EntryGetRecordOutput<'_>) -> Self { use jacquard_common::IntoStatic; output.value.into_static() } } impl jacquard_common::types::collection::Collection for Entry<'_> { const NSID: &'static str = "sh.weaver.notebook.entry"; type Record = EntryRecord; } /// Marker type for deserializing records from this collection. #[derive(Debug, serde::Serialize, serde::Deserialize)] pub struct EntryRecord; impl jacquard_common::xrpc::XrpcResp for EntryRecord { const NSID: &'static str = "sh.weaver.notebook.entry"; const ENCODING: &'static str = "application/json"; type Output<'de> = EntryGetRecordOutput<'de>; type Err<'de> = jacquard_common::types::collection::RecordError<'de>; } impl jacquard_common::types::collection::Collection for EntryRecord { const NSID: &'static str = "sh.weaver.notebook.entry"; type Record = EntryRecord; } impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Entry<'a> { fn nsid() -> &'static str { "sh.weaver.notebook.entry" } fn def_name() -> &'static str { "main" } fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { lexicon_doc_sh_weaver_notebook_entry() } fn validate( &self, ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { Ok(()) } }