atproto blogging
at main 624 lines 21 kB view raw
1// @generated by jacquard-lexicon. DO NOT EDIT. 2// 3// Lexicon: com.atproto.label.subscribeLabels 4// 5// This file was automatically generated from Lexicon schemas. 6// Any manual changes will be overwritten on the next regeneration. 7 8#[jacquard_derive::lexicon] 9#[derive( 10 serde::Serialize, 11 serde::Deserialize, 12 Debug, 13 Clone, 14 PartialEq, 15 Eq, 16 jacquard_derive::IntoStatic, 17 Default 18)] 19#[serde(rename_all = "camelCase")] 20pub struct Info<'a> { 21 #[serde(skip_serializing_if = "std::option::Option::is_none")] 22 #[serde(borrow)] 23 pub message: std::option::Option<jacquard_common::CowStr<'a>>, 24 #[serde(borrow)] 25 pub name: InfoName<'a>, 26} 27 28#[derive(Debug, Clone, PartialEq, Eq, Hash)] 29pub enum InfoName<'a> { 30 OutdatedCursor, 31 Other(jacquard_common::CowStr<'a>), 32} 33 34impl<'a> InfoName<'a> { 35 pub fn as_str(&self) -> &str { 36 match self { 37 Self::OutdatedCursor => "OutdatedCursor", 38 Self::Other(s) => s.as_ref(), 39 } 40 } 41} 42 43impl<'a> From<&'a str> for InfoName<'a> { 44 fn from(s: &'a str) -> Self { 45 match s { 46 "OutdatedCursor" => Self::OutdatedCursor, 47 _ => Self::Other(jacquard_common::CowStr::from(s)), 48 } 49 } 50} 51 52impl<'a> From<String> for InfoName<'a> { 53 fn from(s: String) -> Self { 54 match s.as_str() { 55 "OutdatedCursor" => Self::OutdatedCursor, 56 _ => Self::Other(jacquard_common::CowStr::from(s)), 57 } 58 } 59} 60 61impl<'a> core::fmt::Display for InfoName<'a> { 62 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 63 write!(f, "{}", self.as_str()) 64 } 65} 66 67impl<'a> AsRef<str> for InfoName<'a> { 68 fn as_ref(&self) -> &str { 69 self.as_str() 70 } 71} 72 73impl<'a> serde::Serialize for InfoName<'a> { 74 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> 75 where 76 S: serde::Serializer, 77 { 78 serializer.serialize_str(self.as_str()) 79 } 80} 81 82impl<'de, 'a> serde::Deserialize<'de> for InfoName<'a> 83where 84 'de: 'a, 85{ 86 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> 87 where 88 D: serde::Deserializer<'de>, 89 { 90 let s = <&'de str>::deserialize(deserializer)?; 91 Ok(Self::from(s)) 92 } 93} 94 95impl<'a> Default for InfoName<'a> { 96 fn default() -> Self { 97 Self::Other(Default::default()) 98 } 99} 100 101impl jacquard_common::IntoStatic for InfoName<'_> { 102 type Output = InfoName<'static>; 103 fn into_static(self) -> Self::Output { 104 match self { 105 InfoName::OutdatedCursor => InfoName::OutdatedCursor, 106 InfoName::Other(v) => InfoName::Other(v.into_static()), 107 } 108 } 109} 110 111fn lexicon_doc_com_atproto_label_subscribeLabels() -> ::jacquard_lexicon::lexicon::LexiconDoc< 112 'static, 113> { 114 ::jacquard_lexicon::lexicon::LexiconDoc { 115 lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, 116 id: ::jacquard_common::CowStr::new_static("com.atproto.label.subscribeLabels"), 117 revision: None, 118 description: None, 119 defs: { 120 let mut map = ::alloc::collections::BTreeMap::new(); 121 map.insert( 122 ::jacquard_common::smol_str::SmolStr::new_static("info"), 123 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 124 description: None, 125 required: Some( 126 vec![::jacquard_common::smol_str::SmolStr::new_static("name")], 127 ), 128 nullable: None, 129 properties: { 130 #[allow(unused_mut)] 131 let mut map = ::alloc::collections::BTreeMap::new(); 132 map.insert( 133 ::jacquard_common::smol_str::SmolStr::new_static("message"), 134 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 135 description: None, 136 format: None, 137 default: None, 138 min_length: None, 139 max_length: None, 140 min_graphemes: None, 141 max_graphemes: None, 142 r#enum: None, 143 r#const: None, 144 known_values: None, 145 }), 146 ); 147 map.insert( 148 ::jacquard_common::smol_str::SmolStr::new_static("name"), 149 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 150 description: None, 151 format: None, 152 default: None, 153 min_length: None, 154 max_length: None, 155 min_graphemes: None, 156 max_graphemes: None, 157 r#enum: None, 158 r#const: None, 159 known_values: None, 160 }), 161 ); 162 map 163 }, 164 }), 165 ); 166 map.insert( 167 ::jacquard_common::smol_str::SmolStr::new_static("labels"), 168 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 169 description: None, 170 required: Some( 171 vec![ 172 ::jacquard_common::smol_str::SmolStr::new_static("seq"), 173 ::jacquard_common::smol_str::SmolStr::new_static("labels") 174 ], 175 ), 176 nullable: None, 177 properties: { 178 #[allow(unused_mut)] 179 let mut map = ::alloc::collections::BTreeMap::new(); 180 map.insert( 181 ::jacquard_common::smol_str::SmolStr::new_static("labels"), 182 ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray { 183 description: None, 184 items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef { 185 description: None, 186 r#ref: ::jacquard_common::CowStr::new_static( 187 "com.atproto.label.defs#label", 188 ), 189 }), 190 min_length: None, 191 max_length: None, 192 }), 193 ); 194 map.insert( 195 ::jacquard_common::smol_str::SmolStr::new_static("seq"), 196 ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger { 197 description: None, 198 default: None, 199 minimum: None, 200 maximum: None, 201 r#enum: None, 202 r#const: None, 203 }), 204 ); 205 map 206 }, 207 }), 208 ); 209 map.insert( 210 ::jacquard_common::smol_str::SmolStr::new_static("main"), 211 ::jacquard_lexicon::lexicon::LexUserType::XrpcSubscription(::jacquard_lexicon::lexicon::LexXrpcSubscription { 212 description: None, 213 parameters: Some( 214 ::jacquard_lexicon::lexicon::LexXrpcSubscriptionParameter::Params(::jacquard_lexicon::lexicon::LexXrpcParameters { 215 description: None, 216 required: None, 217 properties: { 218 #[allow(unused_mut)] 219 let mut map = ::alloc::collections::BTreeMap::new(); 220 map.insert( 221 ::jacquard_common::smol_str::SmolStr::new_static("cursor"), 222 ::jacquard_lexicon::lexicon::LexXrpcParametersProperty::Integer(::jacquard_lexicon::lexicon::LexInteger { 223 description: None, 224 default: None, 225 minimum: None, 226 maximum: None, 227 r#enum: None, 228 r#const: None, 229 }), 230 ); 231 map 232 }, 233 }), 234 ), 235 message: None, 236 infos: None, 237 errors: None, 238 }), 239 ); 240 map 241 }, 242 } 243} 244 245impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Info<'a> { 246 fn nsid() -> &'static str { 247 "com.atproto.label.subscribeLabels" 248 } 249 fn def_name() -> &'static str { 250 "info" 251 } 252 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { 253 lexicon_doc_com_atproto_label_subscribeLabels() 254 } 255 fn validate( 256 &self, 257 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { 258 Ok(()) 259 } 260} 261 262#[jacquard_derive::lexicon] 263#[derive( 264 serde::Serialize, 265 serde::Deserialize, 266 Debug, 267 Clone, 268 PartialEq, 269 Eq, 270 jacquard_derive::IntoStatic 271)] 272#[serde(rename_all = "camelCase")] 273pub struct Labels<'a> { 274 #[serde(borrow)] 275 pub labels: Vec<crate::com_atproto::label::Label<'a>>, 276 pub seq: i64, 277} 278 279pub mod labels_state { 280 281 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 282 #[allow(unused)] 283 use ::core::marker::PhantomData; 284 mod sealed { 285 pub trait Sealed {} 286 } 287 /// State trait tracking which required fields have been set 288 pub trait State: sealed::Sealed { 289 type Labels; 290 type Seq; 291 } 292 /// Empty state - all required fields are unset 293 pub struct Empty(()); 294 impl sealed::Sealed for Empty {} 295 impl State for Empty { 296 type Labels = Unset; 297 type Seq = Unset; 298 } 299 ///State transition - sets the `labels` field to Set 300 pub struct SetLabels<S: State = Empty>(PhantomData<fn() -> S>); 301 impl<S: State> sealed::Sealed for SetLabels<S> {} 302 impl<S: State> State for SetLabels<S> { 303 type Labels = Set<members::labels>; 304 type Seq = S::Seq; 305 } 306 ///State transition - sets the `seq` field to Set 307 pub struct SetSeq<S: State = Empty>(PhantomData<fn() -> S>); 308 impl<S: State> sealed::Sealed for SetSeq<S> {} 309 impl<S: State> State for SetSeq<S> { 310 type Labels = S::Labels; 311 type Seq = Set<members::seq>; 312 } 313 /// Marker types for field names 314 #[allow(non_camel_case_types)] 315 pub mod members { 316 ///Marker type for the `labels` field 317 pub struct labels(()); 318 ///Marker type for the `seq` field 319 pub struct seq(()); 320 } 321} 322 323/// Builder for constructing an instance of this type 324pub struct LabelsBuilder<'a, S: labels_state::State> { 325 _phantom_state: ::core::marker::PhantomData<fn() -> S>, 326 __unsafe_private_named: ( 327 ::core::option::Option<Vec<crate::com_atproto::label::Label<'a>>>, 328 ::core::option::Option<i64>, 329 ), 330 _phantom: ::core::marker::PhantomData<&'a ()>, 331} 332 333impl<'a> Labels<'a> { 334 /// Create a new builder for this type 335 pub fn new() -> LabelsBuilder<'a, labels_state::Empty> { 336 LabelsBuilder::new() 337 } 338} 339 340impl<'a> LabelsBuilder<'a, labels_state::Empty> { 341 /// Create a new builder with all fields unset 342 pub fn new() -> Self { 343 LabelsBuilder { 344 _phantom_state: ::core::marker::PhantomData, 345 __unsafe_private_named: (None, None), 346 _phantom: ::core::marker::PhantomData, 347 } 348 } 349} 350 351impl<'a, S> LabelsBuilder<'a, S> 352where 353 S: labels_state::State, 354 S::Labels: labels_state::IsUnset, 355{ 356 /// Set the `labels` field (required) 357 pub fn labels( 358 mut self, 359 value: impl Into<Vec<crate::com_atproto::label::Label<'a>>>, 360 ) -> LabelsBuilder<'a, labels_state::SetLabels<S>> { 361 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); 362 LabelsBuilder { 363 _phantom_state: ::core::marker::PhantomData, 364 __unsafe_private_named: self.__unsafe_private_named, 365 _phantom: ::core::marker::PhantomData, 366 } 367 } 368} 369 370impl<'a, S> LabelsBuilder<'a, S> 371where 372 S: labels_state::State, 373 S::Seq: labels_state::IsUnset, 374{ 375 /// Set the `seq` field (required) 376 pub fn seq( 377 mut self, 378 value: impl Into<i64>, 379 ) -> LabelsBuilder<'a, labels_state::SetSeq<S>> { 380 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); 381 LabelsBuilder { 382 _phantom_state: ::core::marker::PhantomData, 383 __unsafe_private_named: self.__unsafe_private_named, 384 _phantom: ::core::marker::PhantomData, 385 } 386 } 387} 388 389impl<'a, S> LabelsBuilder<'a, S> 390where 391 S: labels_state::State, 392 S::Labels: labels_state::IsSet, 393 S::Seq: labels_state::IsSet, 394{ 395 /// Build the final struct 396 pub fn build(self) -> Labels<'a> { 397 Labels { 398 labels: self.__unsafe_private_named.0.unwrap(), 399 seq: self.__unsafe_private_named.1.unwrap(), 400 extra_data: Default::default(), 401 } 402 } 403 /// Build the final struct with custom extra_data 404 pub fn build_with_data( 405 self, 406 extra_data: std::collections::BTreeMap< 407 jacquard_common::smol_str::SmolStr, 408 jacquard_common::types::value::Data<'a>, 409 >, 410 ) -> Labels<'a> { 411 Labels { 412 labels: self.__unsafe_private_named.0.unwrap(), 413 seq: self.__unsafe_private_named.1.unwrap(), 414 extra_data: Some(extra_data), 415 } 416 } 417} 418 419impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Labels<'a> { 420 fn nsid() -> &'static str { 421 "com.atproto.label.subscribeLabels" 422 } 423 fn def_name() -> &'static str { 424 "labels" 425 } 426 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { 427 lexicon_doc_com_atproto_label_subscribeLabels() 428 } 429 fn validate( 430 &self, 431 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { 432 Ok(()) 433 } 434} 435 436#[derive( 437 serde::Serialize, 438 serde::Deserialize, 439 Debug, 440 Clone, 441 PartialEq, 442 Eq, 443 jacquard_derive::IntoStatic 444)] 445#[serde(rename_all = "camelCase")] 446pub struct SubscribeLabels { 447 #[serde(skip_serializing_if = "std::option::Option::is_none")] 448 pub cursor: std::option::Option<i64>, 449} 450 451pub mod subscribe_labels_state { 452 453 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 454 #[allow(unused)] 455 use ::core::marker::PhantomData; 456 mod sealed { 457 pub trait Sealed {} 458 } 459 /// State trait tracking which required fields have been set 460 pub trait State: sealed::Sealed {} 461 /// Empty state - all required fields are unset 462 pub struct Empty(()); 463 impl sealed::Sealed for Empty {} 464 impl State for Empty {} 465 /// Marker types for field names 466 #[allow(non_camel_case_types)] 467 pub mod members {} 468} 469 470/// Builder for constructing an instance of this type 471pub struct SubscribeLabelsBuilder<S: subscribe_labels_state::State> { 472 _phantom_state: ::core::marker::PhantomData<fn() -> S>, 473 __unsafe_private_named: (::core::option::Option<i64>,), 474} 475 476impl SubscribeLabels { 477 /// Create a new builder for this type 478 pub fn new() -> SubscribeLabelsBuilder<subscribe_labels_state::Empty> { 479 SubscribeLabelsBuilder::new() 480 } 481} 482 483impl SubscribeLabelsBuilder<subscribe_labels_state::Empty> { 484 /// Create a new builder with all fields unset 485 pub fn new() -> Self { 486 SubscribeLabelsBuilder { 487 _phantom_state: ::core::marker::PhantomData, 488 __unsafe_private_named: (None,), 489 } 490 } 491} 492 493impl<S: subscribe_labels_state::State> SubscribeLabelsBuilder<S> { 494 /// Set the `cursor` field (optional) 495 pub fn cursor(mut self, value: impl Into<Option<i64>>) -> Self { 496 self.__unsafe_private_named.0 = value.into(); 497 self 498 } 499 /// Set the `cursor` field to an Option value (optional) 500 pub fn maybe_cursor(mut self, value: Option<i64>) -> Self { 501 self.__unsafe_private_named.0 = value; 502 self 503 } 504} 505 506impl<S> SubscribeLabelsBuilder<S> 507where 508 S: subscribe_labels_state::State, 509{ 510 /// Build the final struct 511 pub fn build(self) -> SubscribeLabels { 512 SubscribeLabels { 513 cursor: self.__unsafe_private_named.0, 514 } 515 } 516} 517 518#[jacquard_derive::open_union] 519#[derive( 520 serde::Serialize, 521 serde::Deserialize, 522 Debug, 523 Clone, 524 PartialEq, 525 Eq, 526 jacquard_derive::IntoStatic 527)] 528#[serde(tag = "$type")] 529#[serde(bound(deserialize = "'de: 'a"))] 530pub enum SubscribeLabelsMessage<'a> { 531 #[serde(rename = "#labels")] 532 Labels(Box<crate::com_atproto::label::subscribe_labels::Labels<'a>>), 533 #[serde(rename = "#info")] 534 Info(Box<crate::com_atproto::label::subscribe_labels::Info<'a>>), 535} 536 537impl<'a> SubscribeLabelsMessage<'a> { 538 /// Decode a framed DAG-CBOR message (header + body). 539 pub fn decode_framed<'de: 'a>( 540 bytes: &'de [u8], 541 ) -> Result<SubscribeLabelsMessage<'a>, jacquard_common::error::DecodeError> { 542 let (header, body) = jacquard_common::xrpc::subscription::parse_event_header( 543 bytes, 544 )?; 545 match header.t.as_str() { 546 "#labels" => { 547 let variant = serde_ipld_dagcbor::from_slice(body)?; 548 Ok(Self::Labels(Box::new(variant))) 549 } 550 "#info" => { 551 let variant = serde_ipld_dagcbor::from_slice(body)?; 552 Ok(Self::Info(Box::new(variant))) 553 } 554 unknown => { 555 Err( 556 jacquard_common::error::DecodeError::UnknownEventType(unknown.into()), 557 ) 558 } 559 } 560 } 561} 562 563#[jacquard_derive::open_union] 564#[derive( 565 serde::Serialize, 566 serde::Deserialize, 567 Debug, 568 Clone, 569 PartialEq, 570 Eq, 571 thiserror::Error, 572 miette::Diagnostic, 573 jacquard_derive::IntoStatic 574)] 575#[serde(tag = "error", content = "message")] 576#[serde(bound(deserialize = "'de: 'a"))] 577pub enum SubscribeLabelsError<'a> { 578 #[serde(rename = "FutureCursor")] 579 FutureCursor(std::option::Option<jacquard_common::CowStr<'a>>), 580} 581 582impl core::fmt::Display for SubscribeLabelsError<'_> { 583 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 584 match self { 585 Self::FutureCursor(msg) => { 586 write!(f, "FutureCursor")?; 587 if let Some(msg) = msg { 588 write!(f, ": {}", msg)?; 589 } 590 Ok(()) 591 } 592 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err), 593 } 594 } 595} 596 597///Stream response type for 598///com.atproto.label.subscribeLabels 599pub struct SubscribeLabelsStream; 600impl jacquard_common::xrpc::SubscriptionResp for SubscribeLabelsStream { 601 const NSID: &'static str = "com.atproto.label.subscribeLabels"; 602 const ENCODING: jacquard_common::xrpc::MessageEncoding = jacquard_common::xrpc::MessageEncoding::DagCbor; 603 type Message<'de> = SubscribeLabelsMessage<'de>; 604 type Error<'de> = SubscribeLabelsError<'de>; 605 fn decode_message<'de>( 606 bytes: &'de [u8], 607 ) -> Result<Self::Message<'de>, jacquard_common::error::DecodeError> { 608 SubscribeLabelsMessage::decode_framed(bytes) 609 } 610} 611 612impl jacquard_common::xrpc::XrpcSubscription for SubscribeLabels { 613 const NSID: &'static str = "com.atproto.label.subscribeLabels"; 614 const ENCODING: jacquard_common::xrpc::MessageEncoding = jacquard_common::xrpc::MessageEncoding::DagCbor; 615 type Stream = SubscribeLabelsStream; 616} 617 618pub struct SubscribeLabelsEndpoint; 619impl jacquard_common::xrpc::SubscriptionEndpoint for SubscribeLabelsEndpoint { 620 const PATH: &'static str = "/xrpc/com.atproto.label.subscribeLabels"; 621 const ENCODING: jacquard_common::xrpc::MessageEncoding = jacquard_common::xrpc::MessageEncoding::DagCbor; 622 type Params<'de> = SubscribeLabels; 623 type Stream = SubscribeLabelsStream; 624}