atproto blogging
at main 501 lines 20 kB view raw
1// @generated by jacquard-lexicon. DO NOT EDIT. 2// 3// Lexicon: app.bsky.feed.postgate 4// 5// This file was automatically generated from Lexicon schemas. 6// Any manual changes will be overwritten on the next regeneration. 7 8/// Disables embedding of this post. 9#[jacquard_derive::lexicon] 10#[derive( 11 serde::Serialize, 12 serde::Deserialize, 13 Debug, 14 Clone, 15 PartialEq, 16 Eq, 17 jacquard_derive::IntoStatic, 18 Default 19)] 20#[serde(rename_all = "camelCase")] 21pub struct DisableRule<'a> {} 22fn lexicon_doc_app_bsky_feed_postgate() -> ::jacquard_lexicon::lexicon::LexiconDoc< 23 'static, 24> { 25 ::jacquard_lexicon::lexicon::LexiconDoc { 26 lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, 27 id: ::jacquard_common::CowStr::new_static("app.bsky.feed.postgate"), 28 revision: None, 29 description: None, 30 defs: { 31 let mut map = ::alloc::collections::BTreeMap::new(); 32 map.insert( 33 ::jacquard_common::smol_str::SmolStr::new_static("disableRule"), 34 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 35 description: Some( 36 ::jacquard_common::CowStr::new_static( 37 "Disables embedding of this post.", 38 ), 39 ), 40 required: None, 41 nullable: None, 42 properties: { 43 #[allow(unused_mut)] 44 let mut map = ::alloc::collections::BTreeMap::new(); 45 map 46 }, 47 }), 48 ); 49 map.insert( 50 ::jacquard_common::smol_str::SmolStr::new_static("main"), 51 ::jacquard_lexicon::lexicon::LexUserType::Record(::jacquard_lexicon::lexicon::LexRecord { 52 description: Some( 53 ::jacquard_common::CowStr::new_static( 54 "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.", 55 ), 56 ), 57 key: Some(::jacquard_common::CowStr::new_static("tid")), 58 record: ::jacquard_lexicon::lexicon::LexRecordRecord::Object(::jacquard_lexicon::lexicon::LexObject { 59 description: None, 60 required: Some( 61 vec![ 62 ::jacquard_common::smol_str::SmolStr::new_static("post"), 63 ::jacquard_common::smol_str::SmolStr::new_static("createdAt") 64 ], 65 ), 66 nullable: None, 67 properties: { 68 #[allow(unused_mut)] 69 let mut map = ::alloc::collections::BTreeMap::new(); 70 map.insert( 71 ::jacquard_common::smol_str::SmolStr::new_static( 72 "createdAt", 73 ), 74 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 75 description: None, 76 format: Some( 77 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime, 78 ), 79 default: None, 80 min_length: None, 81 max_length: None, 82 min_graphemes: None, 83 max_graphemes: None, 84 r#enum: None, 85 r#const: None, 86 known_values: None, 87 }), 88 ); 89 map.insert( 90 ::jacquard_common::smol_str::SmolStr::new_static( 91 "detachedEmbeddingUris", 92 ), 93 ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray { 94 description: Some( 95 ::jacquard_common::CowStr::new_static( 96 "List of AT-URIs embedding this post that the author has detached from.", 97 ), 98 ), 99 items: ::jacquard_lexicon::lexicon::LexArrayItem::String(::jacquard_lexicon::lexicon::LexString { 100 description: None, 101 format: Some( 102 ::jacquard_lexicon::lexicon::LexStringFormat::AtUri, 103 ), 104 default: None, 105 min_length: None, 106 max_length: None, 107 min_graphemes: None, 108 max_graphemes: None, 109 r#enum: None, 110 r#const: None, 111 known_values: None, 112 }), 113 min_length: None, 114 max_length: Some(50usize), 115 }), 116 ); 117 map.insert( 118 ::jacquard_common::smol_str::SmolStr::new_static( 119 "embeddingRules", 120 ), 121 ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray { 122 description: Some( 123 ::jacquard_common::CowStr::new_static( 124 "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.", 125 ), 126 ), 127 items: ::jacquard_lexicon::lexicon::LexArrayItem::Union(::jacquard_lexicon::lexicon::LexRefUnion { 128 description: None, 129 refs: vec![ 130 ::jacquard_common::CowStr::new_static("#disableRule") 131 ], 132 closed: None, 133 }), 134 min_length: None, 135 max_length: Some(5usize), 136 }), 137 ); 138 map.insert( 139 ::jacquard_common::smol_str::SmolStr::new_static("post"), 140 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 141 description: Some( 142 ::jacquard_common::CowStr::new_static( 143 "Reference (AT-URI) to the post record.", 144 ), 145 ), 146 format: Some( 147 ::jacquard_lexicon::lexicon::LexStringFormat::AtUri, 148 ), 149 default: None, 150 min_length: None, 151 max_length: None, 152 min_graphemes: None, 153 max_graphemes: None, 154 r#enum: None, 155 r#const: None, 156 known_values: None, 157 }), 158 ); 159 map 160 }, 161 }), 162 }), 163 ); 164 map 165 }, 166 } 167} 168 169impl<'a> ::jacquard_lexicon::schema::LexiconSchema for DisableRule<'a> { 170 fn nsid() -> &'static str { 171 "app.bsky.feed.postgate" 172 } 173 fn def_name() -> &'static str { 174 "disableRule" 175 } 176 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { 177 lexicon_doc_app_bsky_feed_postgate() 178 } 179 fn validate( 180 &self, 181 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { 182 Ok(()) 183 } 184} 185 186/// 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. 187#[jacquard_derive::lexicon] 188#[derive( 189 serde::Serialize, 190 serde::Deserialize, 191 Debug, 192 Clone, 193 PartialEq, 194 Eq, 195 jacquard_derive::IntoStatic 196)] 197#[serde(rename_all = "camelCase")] 198pub struct Postgate<'a> { 199 pub created_at: jacquard_common::types::string::Datetime, 200 /// List of AT-URIs embedding this post that the author has detached from. 201 #[serde(skip_serializing_if = "std::option::Option::is_none")] 202 #[serde(borrow)] 203 pub detached_embedding_uris: std::option::Option< 204 Vec<jacquard_common::types::string::AtUri<'a>>, 205 >, 206 /// 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. 207 #[serde(skip_serializing_if = "std::option::Option::is_none")] 208 #[serde(borrow)] 209 pub embedding_rules: std::option::Option< 210 Vec<crate::app_bsky::feed::postgate::DisableRule<'a>>, 211 >, 212 /// Reference (AT-URI) to the post record. 213 #[serde(borrow)] 214 pub post: jacquard_common::types::string::AtUri<'a>, 215} 216 217pub mod postgate_state { 218 219 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 220 #[allow(unused)] 221 use ::core::marker::PhantomData; 222 mod sealed { 223 pub trait Sealed {} 224 } 225 /// State trait tracking which required fields have been set 226 pub trait State: sealed::Sealed { 227 type Post; 228 type CreatedAt; 229 } 230 /// Empty state - all required fields are unset 231 pub struct Empty(()); 232 impl sealed::Sealed for Empty {} 233 impl State for Empty { 234 type Post = Unset; 235 type CreatedAt = Unset; 236 } 237 ///State transition - sets the `post` field to Set 238 pub struct SetPost<S: State = Empty>(PhantomData<fn() -> S>); 239 impl<S: State> sealed::Sealed for SetPost<S> {} 240 impl<S: State> State for SetPost<S> { 241 type Post = Set<members::post>; 242 type CreatedAt = S::CreatedAt; 243 } 244 ///State transition - sets the `created_at` field to Set 245 pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>); 246 impl<S: State> sealed::Sealed for SetCreatedAt<S> {} 247 impl<S: State> State for SetCreatedAt<S> { 248 type Post = S::Post; 249 type CreatedAt = Set<members::created_at>; 250 } 251 /// Marker types for field names 252 #[allow(non_camel_case_types)] 253 pub mod members { 254 ///Marker type for the `post` field 255 pub struct post(()); 256 ///Marker type for the `created_at` field 257 pub struct created_at(()); 258 } 259} 260 261/// Builder for constructing an instance of this type 262pub struct PostgateBuilder<'a, S: postgate_state::State> { 263 _phantom_state: ::core::marker::PhantomData<fn() -> S>, 264 __unsafe_private_named: ( 265 ::core::option::Option<jacquard_common::types::string::Datetime>, 266 ::core::option::Option<Vec<jacquard_common::types::string::AtUri<'a>>>, 267 ::core::option::Option<Vec<crate::app_bsky::feed::postgate::DisableRule<'a>>>, 268 ::core::option::Option<jacquard_common::types::string::AtUri<'a>>, 269 ), 270 _phantom: ::core::marker::PhantomData<&'a ()>, 271} 272 273impl<'a> Postgate<'a> { 274 /// Create a new builder for this type 275 pub fn new() -> PostgateBuilder<'a, postgate_state::Empty> { 276 PostgateBuilder::new() 277 } 278} 279 280impl<'a> PostgateBuilder<'a, postgate_state::Empty> { 281 /// Create a new builder with all fields unset 282 pub fn new() -> Self { 283 PostgateBuilder { 284 _phantom_state: ::core::marker::PhantomData, 285 __unsafe_private_named: (None, None, None, None), 286 _phantom: ::core::marker::PhantomData, 287 } 288 } 289} 290 291impl<'a, S> PostgateBuilder<'a, S> 292where 293 S: postgate_state::State, 294 S::CreatedAt: postgate_state::IsUnset, 295{ 296 /// Set the `createdAt` field (required) 297 pub fn created_at( 298 mut self, 299 value: impl Into<jacquard_common::types::string::Datetime>, 300 ) -> PostgateBuilder<'a, postgate_state::SetCreatedAt<S>> { 301 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); 302 PostgateBuilder { 303 _phantom_state: ::core::marker::PhantomData, 304 __unsafe_private_named: self.__unsafe_private_named, 305 _phantom: ::core::marker::PhantomData, 306 } 307 } 308} 309 310impl<'a, S: postgate_state::State> PostgateBuilder<'a, S> { 311 /// Set the `detachedEmbeddingUris` field (optional) 312 pub fn detached_embedding_uris( 313 mut self, 314 value: impl Into<Option<Vec<jacquard_common::types::string::AtUri<'a>>>>, 315 ) -> Self { 316 self.__unsafe_private_named.1 = value.into(); 317 self 318 } 319 /// Set the `detachedEmbeddingUris` field to an Option value (optional) 320 pub fn maybe_detached_embedding_uris( 321 mut self, 322 value: Option<Vec<jacquard_common::types::string::AtUri<'a>>>, 323 ) -> Self { 324 self.__unsafe_private_named.1 = value; 325 self 326 } 327} 328 329impl<'a, S: postgate_state::State> PostgateBuilder<'a, S> { 330 /// Set the `embeddingRules` field (optional) 331 pub fn embedding_rules( 332 mut self, 333 value: impl Into<Option<Vec<crate::app_bsky::feed::postgate::DisableRule<'a>>>>, 334 ) -> Self { 335 self.__unsafe_private_named.2 = value.into(); 336 self 337 } 338 /// Set the `embeddingRules` field to an Option value (optional) 339 pub fn maybe_embedding_rules( 340 mut self, 341 value: Option<Vec<crate::app_bsky::feed::postgate::DisableRule<'a>>>, 342 ) -> Self { 343 self.__unsafe_private_named.2 = value; 344 self 345 } 346} 347 348impl<'a, S> PostgateBuilder<'a, S> 349where 350 S: postgate_state::State, 351 S::Post: postgate_state::IsUnset, 352{ 353 /// Set the `post` field (required) 354 pub fn post( 355 mut self, 356 value: impl Into<jacquard_common::types::string::AtUri<'a>>, 357 ) -> PostgateBuilder<'a, postgate_state::SetPost<S>> { 358 self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into()); 359 PostgateBuilder { 360 _phantom_state: ::core::marker::PhantomData, 361 __unsafe_private_named: self.__unsafe_private_named, 362 _phantom: ::core::marker::PhantomData, 363 } 364 } 365} 366 367impl<'a, S> PostgateBuilder<'a, S> 368where 369 S: postgate_state::State, 370 S::Post: postgate_state::IsSet, 371 S::CreatedAt: postgate_state::IsSet, 372{ 373 /// Build the final struct 374 pub fn build(self) -> Postgate<'a> { 375 Postgate { 376 created_at: self.__unsafe_private_named.0.unwrap(), 377 detached_embedding_uris: self.__unsafe_private_named.1, 378 embedding_rules: self.__unsafe_private_named.2, 379 post: self.__unsafe_private_named.3.unwrap(), 380 extra_data: Default::default(), 381 } 382 } 383 /// Build the final struct with custom extra_data 384 pub fn build_with_data( 385 self, 386 extra_data: std::collections::BTreeMap< 387 jacquard_common::smol_str::SmolStr, 388 jacquard_common::types::value::Data<'a>, 389 >, 390 ) -> Postgate<'a> { 391 Postgate { 392 created_at: self.__unsafe_private_named.0.unwrap(), 393 detached_embedding_uris: self.__unsafe_private_named.1, 394 embedding_rules: self.__unsafe_private_named.2, 395 post: self.__unsafe_private_named.3.unwrap(), 396 extra_data: Some(extra_data), 397 } 398 } 399} 400 401impl<'a> Postgate<'a> { 402 pub fn uri( 403 uri: impl Into<jacquard_common::CowStr<'a>>, 404 ) -> Result< 405 jacquard_common::types::uri::RecordUri<'a, PostgateRecord>, 406 jacquard_common::types::uri::UriError, 407 > { 408 jacquard_common::types::uri::RecordUri::try_from_uri( 409 jacquard_common::types::string::AtUri::new_cow(uri.into())?, 410 ) 411 } 412} 413 414/// Typed wrapper for GetRecord response with this collection's record type. 415#[derive( 416 serde::Serialize, 417 serde::Deserialize, 418 Debug, 419 Clone, 420 PartialEq, 421 Eq, 422 jacquard_derive::IntoStatic 423)] 424#[serde(rename_all = "camelCase")] 425pub struct PostgateGetRecordOutput<'a> { 426 #[serde(skip_serializing_if = "std::option::Option::is_none")] 427 #[serde(borrow)] 428 pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>, 429 #[serde(borrow)] 430 pub uri: jacquard_common::types::string::AtUri<'a>, 431 #[serde(borrow)] 432 pub value: Postgate<'a>, 433} 434 435impl From<PostgateGetRecordOutput<'_>> for Postgate<'_> { 436 fn from(output: PostgateGetRecordOutput<'_>) -> Self { 437 use jacquard_common::IntoStatic; 438 output.value.into_static() 439 } 440} 441 442impl jacquard_common::types::collection::Collection for Postgate<'_> { 443 const NSID: &'static str = "app.bsky.feed.postgate"; 444 type Record = PostgateRecord; 445} 446 447/// Marker type for deserializing records from this collection. 448#[derive(Debug, serde::Serialize, serde::Deserialize)] 449pub struct PostgateRecord; 450impl jacquard_common::xrpc::XrpcResp for PostgateRecord { 451 const NSID: &'static str = "app.bsky.feed.postgate"; 452 const ENCODING: &'static str = "application/json"; 453 type Output<'de> = PostgateGetRecordOutput<'de>; 454 type Err<'de> = jacquard_common::types::collection::RecordError<'de>; 455} 456 457impl jacquard_common::types::collection::Collection for PostgateRecord { 458 const NSID: &'static str = "app.bsky.feed.postgate"; 459 type Record = PostgateRecord; 460} 461 462impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Postgate<'a> { 463 fn nsid() -> &'static str { 464 "app.bsky.feed.postgate" 465 } 466 fn def_name() -> &'static str { 467 "main" 468 } 469 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { 470 lexicon_doc_app_bsky_feed_postgate() 471 } 472 fn validate( 473 &self, 474 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { 475 if let Some(ref value) = self.detached_embedding_uris { 476 #[allow(unused_comparisons)] 477 if value.len() > 50usize { 478 return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength { 479 path: ::jacquard_lexicon::validation::ValidationPath::from_field( 480 "detached_embedding_uris", 481 ), 482 max: 50usize, 483 actual: value.len(), 484 }); 485 } 486 } 487 if let Some(ref value) = self.embedding_rules { 488 #[allow(unused_comparisons)] 489 if value.len() > 5usize { 490 return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength { 491 path: ::jacquard_lexicon::validation::ValidationPath::from_field( 492 "embedding_rules", 493 ), 494 max: 5usize, 495 actual: value.len(), 496 }); 497 } 498 } 499 Ok(()) 500 } 501}