// @generated by jacquard-lexicon. DO NOT EDIT. // // Lexicon: app.bsky.feed.postgate // // This file was automatically generated from Lexicon schemas. // Any manual changes will be overwritten on the next regeneration. /// Disables embedding of this post. #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic, Default )] #[serde(rename_all = "camelCase")] pub struct DisableRule<'a> {} fn lexicon_doc_app_bsky_feed_postgate() -> ::jacquard_lexicon::lexicon::LexiconDoc< 'static, > { ::jacquard_lexicon::lexicon::LexiconDoc { lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, id: ::jacquard_common::CowStr::new_static("app.bsky.feed.postgate"), revision: None, description: None, defs: { let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("disableRule"), ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { description: Some( ::jacquard_common::CowStr::new_static( "Disables embedding of this post.", ), ), required: None, nullable: None, properties: { #[allow(unused_mut)] let mut map = ::alloc::collections::BTreeMap::new(); map }, }), ); 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( "Record defining interaction rules for a post. The record key (rkey) of the postgate record must match the record key of the post, and that record must be in the same repository.", ), ), 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("post"), ::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( "createdAt", ), ::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( "detachedEmbeddingUris", ), ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray { description: Some( ::jacquard_common::CowStr::new_static( "List of AT-URIs embedding this post that the author has detached from.", ), ), items: ::jacquard_lexicon::lexicon::LexArrayItem::String(::jacquard_lexicon::lexicon::LexString { description: None, format: Some( ::jacquard_lexicon::lexicon::LexStringFormat::AtUri, ), 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: Some(50usize), }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "embeddingRules", ), ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray { description: Some( ::jacquard_common::CowStr::new_static( "List of rules defining who can embed this post. If value is an empty array or is undefined, no particular rules apply and anyone can embed.", ), ), items: ::jacquard_lexicon::lexicon::LexArrayItem::Union(::jacquard_lexicon::lexicon::LexRefUnion { description: None, refs: vec![ ::jacquard_common::CowStr::new_static("#disableRule") ], closed: None, }), min_length: None, max_length: Some(5usize), }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("post"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: Some( ::jacquard_common::CowStr::new_static( "Reference (AT-URI) to the post record.", ), ), format: Some( ::jacquard_lexicon::lexicon::LexStringFormat::AtUri, ), 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 DisableRule<'a> { fn nsid() -> &'static str { "app.bsky.feed.postgate" } fn def_name() -> &'static str { "disableRule" } fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { lexicon_doc_app_bsky_feed_postgate() } fn validate( &self, ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { Ok(()) } } /// Record defining interaction rules for a post. The record key (rkey) of the postgate record must match the record key of the post, and that record must be in the same repository. #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct Postgate<'a> { pub created_at: jacquard_common::types::string::Datetime, /// List of AT-URIs embedding this post that the author has detached from. #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub detached_embedding_uris: std::option::Option< Vec>, >, /// List of rules defining who can embed this post. If value is an empty array or is undefined, no particular rules apply and anyone can embed. #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub embedding_rules: std::option::Option< Vec>, >, /// Reference (AT-URI) to the post record. #[serde(borrow)] pub post: jacquard_common::types::string::AtUri<'a>, } pub mod postgate_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 Post; type CreatedAt; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Post = Unset; type CreatedAt = Unset; } ///State transition - sets the `post` field to Set pub struct SetPost(PhantomData S>); impl sealed::Sealed for SetPost {} impl State for SetPost { type Post = Set; type CreatedAt = S::CreatedAt; } ///State transition - sets the `created_at` field to Set pub struct SetCreatedAt(PhantomData S>); impl sealed::Sealed for SetCreatedAt {} impl State for SetCreatedAt { type Post = S::Post; type CreatedAt = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `post` field pub struct post(()); ///Marker type for the `created_at` field pub struct created_at(()); } } /// Builder for constructing an instance of this type pub struct PostgateBuilder<'a, S: postgate_state::State> { _phantom_state: ::core::marker::PhantomData S>, __unsafe_private_named: ( ::core::option::Option, ::core::option::Option>>, ::core::option::Option>>, ::core::option::Option>, ), _phantom: ::core::marker::PhantomData<&'a ()>, } impl<'a> Postgate<'a> { /// Create a new builder for this type pub fn new() -> PostgateBuilder<'a, postgate_state::Empty> { PostgateBuilder::new() } } impl<'a> PostgateBuilder<'a, postgate_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { PostgateBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: (None, None, None, None), _phantom: ::core::marker::PhantomData, } } } impl<'a, S> PostgateBuilder<'a, S> where S: postgate_state::State, S::CreatedAt: postgate_state::IsUnset, { /// Set the `createdAt` field (required) pub fn created_at( mut self, value: impl Into, ) -> PostgateBuilder<'a, postgate_state::SetCreatedAt> { self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); PostgateBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S: postgate_state::State> PostgateBuilder<'a, S> { /// Set the `detachedEmbeddingUris` field (optional) pub fn detached_embedding_uris( mut self, value: impl Into>>>, ) -> Self { self.__unsafe_private_named.1 = value.into(); self } /// Set the `detachedEmbeddingUris` field to an Option value (optional) pub fn maybe_detached_embedding_uris( mut self, value: Option>>, ) -> Self { self.__unsafe_private_named.1 = value; self } } impl<'a, S: postgate_state::State> PostgateBuilder<'a, S> { /// Set the `embeddingRules` field (optional) pub fn embedding_rules( mut self, value: impl Into>>>, ) -> Self { self.__unsafe_private_named.2 = value.into(); self } /// Set the `embeddingRules` field to an Option value (optional) pub fn maybe_embedding_rules( mut self, value: Option>>, ) -> Self { self.__unsafe_private_named.2 = value; self } } impl<'a, S> PostgateBuilder<'a, S> where S: postgate_state::State, S::Post: postgate_state::IsUnset, { /// Set the `post` field (required) pub fn post( mut self, value: impl Into>, ) -> PostgateBuilder<'a, postgate_state::SetPost> { self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into()); PostgateBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> PostgateBuilder<'a, S> where S: postgate_state::State, S::Post: postgate_state::IsSet, S::CreatedAt: postgate_state::IsSet, { /// Build the final struct pub fn build(self) -> Postgate<'a> { Postgate { created_at: self.__unsafe_private_named.0.unwrap(), detached_embedding_uris: self.__unsafe_private_named.1, embedding_rules: self.__unsafe_private_named.2, post: self.__unsafe_private_named.3.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>, >, ) -> Postgate<'a> { Postgate { created_at: self.__unsafe_private_named.0.unwrap(), detached_embedding_uris: self.__unsafe_private_named.1, embedding_rules: self.__unsafe_private_named.2, post: self.__unsafe_private_named.3.unwrap(), extra_data: Some(extra_data), } } } impl<'a> Postgate<'a> { pub fn uri( uri: impl Into>, ) -> Result< jacquard_common::types::uri::RecordUri<'a, PostgateRecord>, 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 PostgateGetRecordOutput<'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: Postgate<'a>, } impl From> for Postgate<'_> { fn from(output: PostgateGetRecordOutput<'_>) -> Self { use jacquard_common::IntoStatic; output.value.into_static() } } impl jacquard_common::types::collection::Collection for Postgate<'_> { const NSID: &'static str = "app.bsky.feed.postgate"; type Record = PostgateRecord; } /// Marker type for deserializing records from this collection. #[derive(Debug, serde::Serialize, serde::Deserialize)] pub struct PostgateRecord; impl jacquard_common::xrpc::XrpcResp for PostgateRecord { const NSID: &'static str = "app.bsky.feed.postgate"; const ENCODING: &'static str = "application/json"; type Output<'de> = PostgateGetRecordOutput<'de>; type Err<'de> = jacquard_common::types::collection::RecordError<'de>; } impl jacquard_common::types::collection::Collection for PostgateRecord { const NSID: &'static str = "app.bsky.feed.postgate"; type Record = PostgateRecord; } impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Postgate<'a> { fn nsid() -> &'static str { "app.bsky.feed.postgate" } fn def_name() -> &'static str { "main" } fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { lexicon_doc_app_bsky_feed_postgate() } fn validate( &self, ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { if let Some(ref value) = self.detached_embedding_uris { #[allow(unused_comparisons)] if value.len() > 50usize { return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength { path: ::jacquard_lexicon::validation::ValidationPath::from_field( "detached_embedding_uris", ), max: 50usize, actual: value.len(), }); } } if let Some(ref value) = self.embedding_rules { #[allow(unused_comparisons)] if value.len() > 5usize { return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength { path: ::jacquard_lexicon::validation::ValidationPath::from_field( "embedding_rules", ), max: 5usize, actual: value.len(), }); } } Ok(()) } }