// @generated by jacquard-lexicon. DO NOT EDIT. // // Lexicon: blog.pckt.post // // This file was automatically generated from Lexicon schemas. // Any manual changes will be overwritten on the next regeneration. #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct Post<'a> { #[serde(borrow)] pub blocks: jacquard_common::types::value::Data<'a>, #[serde(borrow)] pub blog: crate::com_atproto::repo::strong_ref::StrongRef<'a>, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub body_plain: std::option::Option>, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub cover: 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")] pub published_at: std::option::Option, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub tags: std::option::Option>>, #[serde(borrow)] pub title: jacquard_common::CowStr<'a>, #[serde(skip_serializing_if = "std::option::Option::is_none")] pub updated_at: std::option::Option, #[serde(borrow)] pub url: jacquard_common::types::string::Uri<'a>, } pub mod post_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 Title; type Blocks; type Blog; type Url; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Title = Unset; type Blocks = Unset; type Blog = Unset; type Url = Unset; } ///State transition - sets the `title` field to Set pub struct SetTitle(PhantomData S>); impl sealed::Sealed for SetTitle {} impl State for SetTitle { type Title = Set; type Blocks = S::Blocks; type Blog = S::Blog; type Url = S::Url; } ///State transition - sets the `blocks` field to Set pub struct SetBlocks(PhantomData S>); impl sealed::Sealed for SetBlocks {} impl State for SetBlocks { type Title = S::Title; type Blocks = Set; type Blog = S::Blog; type Url = S::Url; } ///State transition - sets the `blog` field to Set pub struct SetBlog(PhantomData S>); impl sealed::Sealed for SetBlog {} impl State for SetBlog { type Title = S::Title; type Blocks = S::Blocks; type Blog = Set; type Url = S::Url; } ///State transition - sets the `url` field to Set pub struct SetUrl(PhantomData S>); impl sealed::Sealed for SetUrl {} impl State for SetUrl { type Title = S::Title; type Blocks = S::Blocks; type Blog = S::Blog; type Url = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `title` field pub struct title(()); ///Marker type for the `blocks` field pub struct blocks(()); ///Marker type for the `blog` field pub struct blog(()); ///Marker type for the `url` field pub struct url(()); } } /// Builder for constructing an instance of this type pub struct PostBuilder<'a, S: post_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> Post<'a> { /// Create a new builder for this type pub fn new() -> PostBuilder<'a, post_state::Empty> { PostBuilder::new() } } impl<'a> PostBuilder<'a, post_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { PostBuilder { _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> PostBuilder<'a, S> where S: post_state::State, S::Blocks: post_state::IsUnset, { /// Set the `blocks` field (required) pub fn blocks( mut self, value: impl Into>, ) -> PostBuilder<'a, post_state::SetBlocks> { self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); PostBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> PostBuilder<'a, S> where S: post_state::State, S::Blog: post_state::IsUnset, { /// Set the `blog` field (required) pub fn blog( mut self, value: impl Into>, ) -> PostBuilder<'a, post_state::SetBlog> { self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); PostBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S: post_state::State> PostBuilder<'a, S> { /// Set the `bodyPlain` field (optional) pub fn body_plain( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.2 = value.into(); self } /// Set the `bodyPlain` field to an Option value (optional) pub fn maybe_body_plain( mut self, value: Option>, ) -> Self { self.__unsafe_private_named.2 = value; self } } impl<'a, S: post_state::State> PostBuilder<'a, S> { /// Set the `cover` field (optional) pub fn cover( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.3 = value.into(); self } /// Set the `cover` field to an Option value (optional) pub fn maybe_cover( mut self, value: Option>, ) -> Self { self.__unsafe_private_named.3 = value; self } } impl<'a, S: post_state::State> PostBuilder<'a, S> { /// Set the `images` field (optional) pub fn images( mut self, value: impl Into>>>, ) -> Self { self.__unsafe_private_named.4 = value.into(); self } /// Set the `images` field to an Option value (optional) pub fn maybe_images( mut self, value: Option>>, ) -> Self { self.__unsafe_private_named.4 = value; self } } impl<'a, S: post_state::State> PostBuilder<'a, S> { /// Set the `publishedAt` field (optional) pub fn published_at( mut self, value: impl Into>, ) -> Self { self.__unsafe_private_named.5 = value.into(); self } /// Set the `publishedAt` field to an Option value (optional) pub fn maybe_published_at( mut self, value: Option, ) -> Self { self.__unsafe_private_named.5 = value; self } } impl<'a, S: post_state::State> PostBuilder<'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> PostBuilder<'a, S> where S: post_state::State, S::Title: post_state::IsUnset, { /// Set the `title` field (required) pub fn title( mut self, value: impl Into>, ) -> PostBuilder<'a, post_state::SetTitle> { self.__unsafe_private_named.7 = ::core::option::Option::Some(value.into()); PostBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S: post_state::State> PostBuilder<'a, S> { /// Set the `updatedAt` field (optional) pub fn updated_at( mut self, value: impl Into>, ) -> Self { self.__unsafe_private_named.8 = 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.8 = value; self } } impl<'a, S> PostBuilder<'a, S> where S: post_state::State, S::Url: post_state::IsUnset, { /// Set the `url` field (required) pub fn url( mut self, value: impl Into>, ) -> PostBuilder<'a, post_state::SetUrl> { self.__unsafe_private_named.9 = ::core::option::Option::Some(value.into()); PostBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> PostBuilder<'a, S> where S: post_state::State, S::Title: post_state::IsSet, S::Blocks: post_state::IsSet, S::Blog: post_state::IsSet, S::Url: post_state::IsSet, { /// Build the final struct pub fn build(self) -> Post<'a> { Post { blocks: self.__unsafe_private_named.0.unwrap(), blog: self.__unsafe_private_named.1.unwrap(), body_plain: self.__unsafe_private_named.2, cover: self.__unsafe_private_named.3, images: self.__unsafe_private_named.4, published_at: self.__unsafe_private_named.5, tags: self.__unsafe_private_named.6, title: self.__unsafe_private_named.7.unwrap(), updated_at: self.__unsafe_private_named.8, url: self.__unsafe_private_named.9.unwrap(), 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>, >, ) -> Post<'a> { Post { blocks: self.__unsafe_private_named.0.unwrap(), blog: self.__unsafe_private_named.1.unwrap(), body_plain: self.__unsafe_private_named.2, cover: self.__unsafe_private_named.3, images: self.__unsafe_private_named.4, published_at: self.__unsafe_private_named.5, tags: self.__unsafe_private_named.6, title: self.__unsafe_private_named.7.unwrap(), updated_at: self.__unsafe_private_named.8, url: self.__unsafe_private_named.9.unwrap(), extra_data: Some(extra_data), } } } impl<'a> Post<'a> { pub fn uri( uri: impl Into>, ) -> Result< jacquard_common::types::uri::RecordUri<'a, PostRecord>, 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 PostGetRecordOutput<'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: Post<'a>, } impl From> for Post<'_> { fn from(output: PostGetRecordOutput<'_>) -> Self { use jacquard_common::IntoStatic; output.value.into_static() } } impl jacquard_common::types::collection::Collection for Post<'_> { const NSID: &'static str = "blog.pckt.post"; type Record = PostRecord; } /// Marker type for deserializing records from this collection. #[derive(Debug, serde::Serialize, serde::Deserialize)] pub struct PostRecord; impl jacquard_common::xrpc::XrpcResp for PostRecord { const NSID: &'static str = "blog.pckt.post"; const ENCODING: &'static str = "application/json"; type Output<'de> = PostGetRecordOutput<'de>; type Err<'de> = jacquard_common::types::collection::RecordError<'de>; } impl jacquard_common::types::collection::Collection for PostRecord { const NSID: &'static str = "blog.pckt.post"; type Record = PostRecord; } impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Post<'a> { fn nsid() -> &'static str { "blog.pckt.post" } fn def_name() -> &'static str { "main" } fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { lexicon_doc_blog_pckt_post() } fn validate( &self, ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { Ok(()) } } fn lexicon_doc_blog_pckt_post() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { ::jacquard_lexicon::lexicon::LexiconDoc { lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, id: ::jacquard_common::CowStr::new_static("blog.pckt.post"), 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: None, 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("title"), ::jacquard_common::smol_str::SmolStr::new_static("blocks"), ::jacquard_common::smol_str::SmolStr::new_static("url"), ::jacquard_common::smol_str::SmolStr::new_static("blog") ], ), nullable: None, properties: { #[allow(unused_mut)] let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("blocks"), ::jacquard_lexicon::lexicon::LexObjectProperty::Union(::jacquard_lexicon::lexicon::LexRefUnion { description: None, refs: vec![], closed: Some(false), }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("blog"), ::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( "bodyPlain", ), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, 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("cover"), ::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("images"), ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray { description: None, items: ::jacquard_lexicon::lexicon::LexArrayItem::Blob(::jacquard_lexicon::lexicon::LexBlob { description: None, accept: None, max_size: None, }), min_length: None, max_length: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "publishedAt", ), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, 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("tags"), ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray { description: None, items: ::jacquard_lexicon::lexicon::LexArrayItem::String(::jacquard_lexicon::lexicon::LexString { description: None, 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, }), min_length: None, max_length: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("title"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, 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( "updatedAt", ), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, 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("url"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, 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 }, }), }), ); map }, } }