// @generated by jacquard-lexicon. DO NOT EDIT. // // Lexicon: site.standard.document // // This file was automatically generated from Lexicon schemas. // Any manual changes will be overwritten on the next regeneration. /// A document record representing a published article, blog post, or other content. Documents can belong to a publication or exist independently. #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct Document<'a> { /// Strong reference to a Bluesky post. Useful to keep track of comments off-platform. #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub bsky_post_ref: std::option::Option< crate::com_atproto::repo::strong_ref::StrongRef<'a>, >, /// Open union used to define the record's content. Each entry must specify a $type and may be extended with other lexicons to support additional content formats. #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub content: std::option::Option>, /// Image to used for thumbnail or cover image. Less than 1MB is size. #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub cover_image: std::option::Option>, /// A brief description or excerpt from the document. #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub description: std::option::Option>, /// Combine with site or publication url to construct a canonical URL to the document. Prepend with a leading slash. #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub path: std::option::Option>, /// Timestamp of the documents publish time. pub published_at: jacquard_common::types::string::Datetime, /// Points to a publication record (at://) or a publication url (https://) for loose documents. Avoid trailing slashes. #[serde(borrow)] pub site: jacquard_common::types::string::Uri<'a>, /// Array of strings used to tag or categorize the document. Avoid prepending tags with hashtags. #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub tags: std::option::Option>>, /// Plaintext representation of the documents contents. Should not contain markdown or other formatting. #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub text_content: std::option::Option>, /// Title of the document. #[serde(borrow)] pub title: jacquard_common::CowStr<'a>, /// Timestamp of the documents last edit. #[serde(skip_serializing_if = "std::option::Option::is_none")] pub updated_at: std::option::Option, } pub mod document_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 Site; type Title; type PublishedAt; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Site = Unset; type Title = Unset; type PublishedAt = Unset; } ///State transition - sets the `site` field to Set pub struct SetSite(PhantomData S>); impl sealed::Sealed for SetSite {} impl State for SetSite { type Site = Set; type Title = S::Title; type PublishedAt = S::PublishedAt; } ///State transition - sets the `title` field to Set pub struct SetTitle(PhantomData S>); impl sealed::Sealed for SetTitle {} impl State for SetTitle { type Site = S::Site; type Title = Set; type PublishedAt = S::PublishedAt; } ///State transition - sets the `published_at` field to Set pub struct SetPublishedAt(PhantomData S>); impl sealed::Sealed for SetPublishedAt {} impl State for SetPublishedAt { type Site = S::Site; type Title = S::Title; type PublishedAt = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `site` field pub struct site(()); ///Marker type for the `title` field pub struct title(()); ///Marker type for the `published_at` field pub struct published_at(()); } } /// Builder for constructing an instance of this type pub struct DocumentBuilder<'a, S: document_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>, ::core::option::Option, ), _phantom: ::core::marker::PhantomData<&'a ()>, } impl<'a> Document<'a> { /// Create a new builder for this type pub fn new() -> DocumentBuilder<'a, document_state::Empty> { DocumentBuilder::new() } } impl<'a> DocumentBuilder<'a, document_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { DocumentBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: ( None, None, None, None, None, None, None, None, None, None, None, ), _phantom: ::core::marker::PhantomData, } } } impl<'a, S: document_state::State> DocumentBuilder<'a, S> { /// Set the `bskyPostRef` field (optional) pub fn bsky_post_ref( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.0 = value.into(); self } /// Set the `bskyPostRef` field to an Option value (optional) pub fn maybe_bsky_post_ref( mut self, value: Option>, ) -> Self { self.__unsafe_private_named.0 = value; self } } impl<'a, S: document_state::State> DocumentBuilder<'a, S> { /// Set the `content` field (optional) pub fn content( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.1 = value.into(); self } /// Set the `content` field to an Option value (optional) pub fn maybe_content( mut self, value: Option>, ) -> Self { self.__unsafe_private_named.1 = value; self } } impl<'a, S: document_state::State> DocumentBuilder<'a, S> { /// Set the `coverImage` field (optional) pub fn cover_image( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.2 = value.into(); self } /// Set the `coverImage` field to an Option value (optional) pub fn maybe_cover_image( mut self, value: Option>, ) -> Self { self.__unsafe_private_named.2 = value; self } } impl<'a, S: document_state::State> DocumentBuilder<'a, S> { /// Set the `description` field (optional) pub fn description( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.3 = value.into(); self } /// Set the `description` field to an Option value (optional) pub fn maybe_description( mut self, value: Option>, ) -> Self { self.__unsafe_private_named.3 = value; self } } impl<'a, S: document_state::State> DocumentBuilder<'a, S> { /// Set the `path` field (optional) pub fn path( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.4 = value.into(); self } /// Set the `path` field to an Option value (optional) pub fn maybe_path(mut self, value: Option>) -> Self { self.__unsafe_private_named.4 = value; self } } impl<'a, S> DocumentBuilder<'a, S> where S: document_state::State, S::PublishedAt: document_state::IsUnset, { /// Set the `publishedAt` field (required) pub fn published_at( mut self, value: impl Into, ) -> DocumentBuilder<'a, document_state::SetPublishedAt> { self.__unsafe_private_named.5 = ::core::option::Option::Some(value.into()); DocumentBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> DocumentBuilder<'a, S> where S: document_state::State, S::Site: document_state::IsUnset, { /// Set the `site` field (required) pub fn site( mut self, value: impl Into>, ) -> DocumentBuilder<'a, document_state::SetSite> { self.__unsafe_private_named.6 = ::core::option::Option::Some(value.into()); DocumentBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S: document_state::State> DocumentBuilder<'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: document_state::State> DocumentBuilder<'a, S> { /// Set the `textContent` field (optional) pub fn text_content( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.8 = value.into(); self } /// Set the `textContent` field to an Option value (optional) pub fn maybe_text_content( mut self, value: Option>, ) -> Self { self.__unsafe_private_named.8 = value; self } } impl<'a, S> DocumentBuilder<'a, S> where S: document_state::State, S::Title: document_state::IsUnset, { /// Set the `title` field (required) pub fn title( mut self, value: impl Into>, ) -> DocumentBuilder<'a, document_state::SetTitle> { self.__unsafe_private_named.9 = ::core::option::Option::Some(value.into()); DocumentBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S: document_state::State> DocumentBuilder<'a, S> { /// Set the `updatedAt` field (optional) pub fn updated_at( mut self, value: impl Into>, ) -> Self { self.__unsafe_private_named.10 = 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.10 = value; self } } impl<'a, S> DocumentBuilder<'a, S> where S: document_state::State, S::Site: document_state::IsSet, S::Title: document_state::IsSet, S::PublishedAt: document_state::IsSet, { /// Build the final struct pub fn build(self) -> Document<'a> { Document { bsky_post_ref: self.__unsafe_private_named.0, content: self.__unsafe_private_named.1, cover_image: self.__unsafe_private_named.2, description: self.__unsafe_private_named.3, path: self.__unsafe_private_named.4, published_at: self.__unsafe_private_named.5.unwrap(), site: self.__unsafe_private_named.6.unwrap(), tags: self.__unsafe_private_named.7, text_content: self.__unsafe_private_named.8, title: self.__unsafe_private_named.9.unwrap(), updated_at: self.__unsafe_private_named.10, 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>, >, ) -> Document<'a> { Document { bsky_post_ref: self.__unsafe_private_named.0, content: self.__unsafe_private_named.1, cover_image: self.__unsafe_private_named.2, description: self.__unsafe_private_named.3, path: self.__unsafe_private_named.4, published_at: self.__unsafe_private_named.5.unwrap(), site: self.__unsafe_private_named.6.unwrap(), tags: self.__unsafe_private_named.7, text_content: self.__unsafe_private_named.8, title: self.__unsafe_private_named.9.unwrap(), updated_at: self.__unsafe_private_named.10, extra_data: Some(extra_data), } } } impl<'a> Document<'a> { pub fn uri( uri: impl Into>, ) -> Result< jacquard_common::types::uri::RecordUri<'a, DocumentRecord>, 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 DocumentGetRecordOutput<'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: Document<'a>, } impl From> for Document<'_> { fn from(output: DocumentGetRecordOutput<'_>) -> Self { use jacquard_common::IntoStatic; output.value.into_static() } } impl jacquard_common::types::collection::Collection for Document<'_> { const NSID: &'static str = "site.standard.document"; type Record = DocumentRecord; } /// Marker type for deserializing records from this collection. #[derive(Debug, serde::Serialize, serde::Deserialize)] pub struct DocumentRecord; impl jacquard_common::xrpc::XrpcResp for DocumentRecord { const NSID: &'static str = "site.standard.document"; const ENCODING: &'static str = "application/json"; type Output<'de> = DocumentGetRecordOutput<'de>; type Err<'de> = jacquard_common::types::collection::RecordError<'de>; } impl jacquard_common::types::collection::Collection for DocumentRecord { const NSID: &'static str = "site.standard.document"; type Record = DocumentRecord; } impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Document<'a> { fn nsid() -> &'static str { "site.standard.document" } fn def_name() -> &'static str { "main" } fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { lexicon_doc_site_standard_document() } fn validate( &self, ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { if let Some(ref value) = self.description { #[allow(unused_comparisons)] if ::len(value.as_ref()) > 3000usize { return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength { path: ::jacquard_lexicon::validation::ValidationPath::from_field( "description", ), max: 3000usize, actual: ::len(value.as_ref()), }); } } if let Some(ref value) = self.description { { let count = ::unicode_segmentation::UnicodeSegmentation::graphemes( value.as_ref(), true, ) .count(); if count > 300usize { return Err(::jacquard_lexicon::validation::ConstraintError::MaxGraphemes { path: ::jacquard_lexicon::validation::ValidationPath::from_field( "description", ), max: 300usize, actual: count, }); } } } { let value = &self.title; #[allow(unused_comparisons)] if ::len(value.as_ref()) > 1280usize { return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength { path: ::jacquard_lexicon::validation::ValidationPath::from_field( "title", ), max: 1280usize, actual: ::len(value.as_ref()), }); } } { let value = &self.title; { let count = ::unicode_segmentation::UnicodeSegmentation::graphemes( value.as_ref(), true, ) .count(); if count > 128usize { return Err(::jacquard_lexicon::validation::ConstraintError::MaxGraphemes { path: ::jacquard_lexicon::validation::ValidationPath::from_field( "title", ), max: 128usize, actual: count, }); } } } Ok(()) } } fn lexicon_doc_site_standard_document() -> ::jacquard_lexicon::lexicon::LexiconDoc< 'static, > { ::jacquard_lexicon::lexicon::LexiconDoc { lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, id: ::jacquard_common::CowStr::new_static("site.standard.document"), 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 document record representing a published article, blog post, or other content. Documents can belong to a publication or exist independently.", ), ), 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("site"), ::jacquard_common::smol_str::SmolStr::new_static("title"), ::jacquard_common::smol_str::SmolStr::new_static("publishedAt") ], ), nullable: None, properties: { #[allow(unused_mut)] let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "bskyPostRef", ), ::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("content"), ::jacquard_lexicon::lexicon::LexObjectProperty::Union(::jacquard_lexicon::lexicon::LexRefUnion { description: Some( ::jacquard_common::CowStr::new_static( "Open union used to define the record's content. Each entry must specify a $type and may be extended with other lexicons to support additional content formats.", ), ), refs: vec![], closed: Some(false), }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "coverImage", ), ::jacquard_lexicon::lexicon::LexObjectProperty::Blob(::jacquard_lexicon::lexicon::LexBlob { description: None, accept: None, max_size: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "description", ), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: Some( ::jacquard_common::CowStr::new_static( "A brief description or excerpt from the document.", ), ), format: None, default: None, min_length: None, max_length: Some(3000usize), min_graphemes: None, max_graphemes: Some(300usize), r#enum: None, r#const: None, known_values: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("path"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: Some( ::jacquard_common::CowStr::new_static( "Combine with site or publication url to construct a canonical URL to the document. Prepend with a leading slash.", ), ), 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( "publishedAt", ), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: Some( ::jacquard_common::CowStr::new_static( "Timestamp of the documents publish time.", ), ), 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("site"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: Some( ::jacquard_common::CowStr::new_static( "Points to a publication record (at://) or a publication url (https://) for loose documents. Avoid trailing slashes.", ), ), format: Some( ::jacquard_lexicon::lexicon::LexStringFormat::Uri, ), 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("tags"), ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray { description: Some( ::jacquard_common::CowStr::new_static( "Array of strings used to tag or categorize the document. Avoid prepending tags with hashtags.", ), ), items: ::jacquard_lexicon::lexicon::LexArrayItem::String(::jacquard_lexicon::lexicon::LexString { description: None, format: None, default: None, min_length: None, max_length: Some(100usize), min_graphemes: None, max_graphemes: Some(50usize), r#enum: None, r#const: None, known_values: None, }), min_length: None, max_length: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "textContent", ), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: Some( ::jacquard_common::CowStr::new_static( "Plaintext representation of the documents contents. Should not contain markdown or other formatting.", ), ), 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("title"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: Some( ::jacquard_common::CowStr::new_static( "Title of the document.", ), ), format: None, default: None, min_length: None, max_length: Some(1280usize), min_graphemes: None, max_graphemes: Some(128usize), r#enum: None, r#const: None, known_values: None, }), ); 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( "Timestamp of the documents last edit.", ), ), 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 }, } }