// @generated by jacquard-lexicon. DO NOT EDIT. // // Lexicon: com.atproto.label.subscribeLabels // // 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, Default )] #[serde(rename_all = "camelCase")] pub struct Info<'a> { #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub message: std::option::Option>, #[serde(borrow)] pub name: InfoName<'a>, } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum InfoName<'a> { OutdatedCursor, Other(jacquard_common::CowStr<'a>), } impl<'a> InfoName<'a> { pub fn as_str(&self) -> &str { match self { Self::OutdatedCursor => "OutdatedCursor", Self::Other(s) => s.as_ref(), } } } impl<'a> From<&'a str> for InfoName<'a> { fn from(s: &'a str) -> Self { match s { "OutdatedCursor" => Self::OutdatedCursor, _ => Self::Other(jacquard_common::CowStr::from(s)), } } } impl<'a> From for InfoName<'a> { fn from(s: String) -> Self { match s.as_str() { "OutdatedCursor" => Self::OutdatedCursor, _ => Self::Other(jacquard_common::CowStr::from(s)), } } } impl<'a> core::fmt::Display for InfoName<'a> { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!(f, "{}", self.as_str()) } } impl<'a> AsRef for InfoName<'a> { fn as_ref(&self) -> &str { self.as_str() } } impl<'a> serde::Serialize for InfoName<'a> { fn serialize(&self, serializer: S) -> Result where S: serde::Serializer, { serializer.serialize_str(self.as_str()) } } impl<'de, 'a> serde::Deserialize<'de> for InfoName<'a> where 'de: 'a, { fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'de>, { let s = <&'de str>::deserialize(deserializer)?; Ok(Self::from(s)) } } impl<'a> Default for InfoName<'a> { fn default() -> Self { Self::Other(Default::default()) } } impl jacquard_common::IntoStatic for InfoName<'_> { type Output = InfoName<'static>; fn into_static(self) -> Self::Output { match self { InfoName::OutdatedCursor => InfoName::OutdatedCursor, InfoName::Other(v) => InfoName::Other(v.into_static()), } } } fn lexicon_doc_com_atproto_label_subscribeLabels() -> ::jacquard_lexicon::lexicon::LexiconDoc< 'static, > { ::jacquard_lexicon::lexicon::LexiconDoc { lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, id: ::jacquard_common::CowStr::new_static("com.atproto.label.subscribeLabels"), revision: None, description: None, defs: { let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("info"), ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { description: None, required: Some( vec![::jacquard_common::smol_str::SmolStr::new_static("name")], ), nullable: None, properties: { #[allow(unused_mut)] let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("message"), ::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("name"), ::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 }, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("labels"), ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { description: None, required: Some( vec![ ::jacquard_common::smol_str::SmolStr::new_static("seq"), ::jacquard_common::smol_str::SmolStr::new_static("labels") ], ), nullable: None, properties: { #[allow(unused_mut)] let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("labels"), ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray { description: None, items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef { description: None, r#ref: ::jacquard_common::CowStr::new_static( "com.atproto.label.defs#label", ), }), min_length: None, max_length: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("seq"), ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger { description: None, default: None, minimum: None, maximum: None, r#enum: None, r#const: None, }), ); map }, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("main"), ::jacquard_lexicon::lexicon::LexUserType::XrpcSubscription(::jacquard_lexicon::lexicon::LexXrpcSubscription { description: None, parameters: Some( ::jacquard_lexicon::lexicon::LexXrpcSubscriptionParameter::Params(::jacquard_lexicon::lexicon::LexXrpcParameters { description: None, required: None, properties: { #[allow(unused_mut)] let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("cursor"), ::jacquard_lexicon::lexicon::LexXrpcParametersProperty::Integer(::jacquard_lexicon::lexicon::LexInteger { description: None, default: None, minimum: None, maximum: None, r#enum: None, r#const: None, }), ); map }, }), ), message: None, infos: None, errors: None, }), ); map }, } } impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Info<'a> { fn nsid() -> &'static str { "com.atproto.label.subscribeLabels" } fn def_name() -> &'static str { "info" } fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { lexicon_doc_com_atproto_label_subscribeLabels() } fn validate( &self, ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { Ok(()) } } #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct Labels<'a> { #[serde(borrow)] pub labels: Vec>, pub seq: i64, } pub mod labels_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 Labels; type Seq; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Labels = Unset; type Seq = Unset; } ///State transition - sets the `labels` field to Set pub struct SetLabels(PhantomData S>); impl sealed::Sealed for SetLabels {} impl State for SetLabels { type Labels = Set; type Seq = S::Seq; } ///State transition - sets the `seq` field to Set pub struct SetSeq(PhantomData S>); impl sealed::Sealed for SetSeq {} impl State for SetSeq { type Labels = S::Labels; type Seq = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `labels` field pub struct labels(()); ///Marker type for the `seq` field pub struct seq(()); } } /// Builder for constructing an instance of this type pub struct LabelsBuilder<'a, S: labels_state::State> { _phantom_state: ::core::marker::PhantomData S>, __unsafe_private_named: ( ::core::option::Option>>, ::core::option::Option, ), _phantom: ::core::marker::PhantomData<&'a ()>, } impl<'a> Labels<'a> { /// Create a new builder for this type pub fn new() -> LabelsBuilder<'a, labels_state::Empty> { LabelsBuilder::new() } } impl<'a> LabelsBuilder<'a, labels_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { LabelsBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: (None, None), _phantom: ::core::marker::PhantomData, } } } impl<'a, S> LabelsBuilder<'a, S> where S: labels_state::State, S::Labels: labels_state::IsUnset, { /// Set the `labels` field (required) pub fn labels( mut self, value: impl Into>>, ) -> LabelsBuilder<'a, labels_state::SetLabels> { self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); LabelsBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> LabelsBuilder<'a, S> where S: labels_state::State, S::Seq: labels_state::IsUnset, { /// Set the `seq` field (required) pub fn seq( mut self, value: impl Into, ) -> LabelsBuilder<'a, labels_state::SetSeq> { self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); LabelsBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> LabelsBuilder<'a, S> where S: labels_state::State, S::Labels: labels_state::IsSet, S::Seq: labels_state::IsSet, { /// Build the final struct pub fn build(self) -> Labels<'a> { Labels { labels: self.__unsafe_private_named.0.unwrap(), seq: self.__unsafe_private_named.1.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>, >, ) -> Labels<'a> { Labels { labels: self.__unsafe_private_named.0.unwrap(), seq: self.__unsafe_private_named.1.unwrap(), extra_data: Some(extra_data), } } } impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Labels<'a> { fn nsid() -> &'static str { "com.atproto.label.subscribeLabels" } fn def_name() -> &'static str { "labels" } fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { lexicon_doc_com_atproto_label_subscribeLabels() } fn validate( &self, ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { Ok(()) } } #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct SubscribeLabels { #[serde(skip_serializing_if = "std::option::Option::is_none")] pub cursor: std::option::Option, } pub mod subscribe_labels_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 {} /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty {} /// Marker types for field names #[allow(non_camel_case_types)] pub mod members {} } /// Builder for constructing an instance of this type pub struct SubscribeLabelsBuilder { _phantom_state: ::core::marker::PhantomData S>, __unsafe_private_named: (::core::option::Option,), } impl SubscribeLabels { /// Create a new builder for this type pub fn new() -> SubscribeLabelsBuilder { SubscribeLabelsBuilder::new() } } impl SubscribeLabelsBuilder { /// Create a new builder with all fields unset pub fn new() -> Self { SubscribeLabelsBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: (None,), } } } impl SubscribeLabelsBuilder { /// Set the `cursor` field (optional) pub fn cursor(mut self, value: impl Into>) -> Self { self.__unsafe_private_named.0 = value.into(); self } /// Set the `cursor` field to an Option value (optional) pub fn maybe_cursor(mut self, value: Option) -> Self { self.__unsafe_private_named.0 = value; self } } impl SubscribeLabelsBuilder where S: subscribe_labels_state::State, { /// Build the final struct pub fn build(self) -> SubscribeLabels { SubscribeLabels { cursor: self.__unsafe_private_named.0, } } } #[jacquard_derive::open_union] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(tag = "$type")] #[serde(bound(deserialize = "'de: 'a"))] pub enum SubscribeLabelsMessage<'a> { #[serde(rename = "#labels")] Labels(Box>), #[serde(rename = "#info")] Info(Box>), } impl<'a> SubscribeLabelsMessage<'a> { /// Decode a framed DAG-CBOR message (header + body). pub fn decode_framed<'de: 'a>( bytes: &'de [u8], ) -> Result, jacquard_common::error::DecodeError> { let (header, body) = jacquard_common::xrpc::subscription::parse_event_header( bytes, )?; match header.t.as_str() { "#labels" => { let variant = serde_ipld_dagcbor::from_slice(body)?; Ok(Self::Labels(Box::new(variant))) } "#info" => { let variant = serde_ipld_dagcbor::from_slice(body)?; Ok(Self::Info(Box::new(variant))) } unknown => { Err( jacquard_common::error::DecodeError::UnknownEventType(unknown.into()), ) } } } } #[jacquard_derive::open_union] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, thiserror::Error, miette::Diagnostic, jacquard_derive::IntoStatic )] #[serde(tag = "error", content = "message")] #[serde(bound(deserialize = "'de: 'a"))] pub enum SubscribeLabelsError<'a> { #[serde(rename = "FutureCursor")] FutureCursor(std::option::Option>), } impl core::fmt::Display for SubscribeLabelsError<'_> { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { match self { Self::FutureCursor(msg) => { write!(f, "FutureCursor")?; if let Some(msg) = msg { write!(f, ": {}", msg)?; } Ok(()) } Self::Unknown(err) => write!(f, "Unknown error: {:?}", err), } } } ///Stream response type for ///com.atproto.label.subscribeLabels pub struct SubscribeLabelsStream; impl jacquard_common::xrpc::SubscriptionResp for SubscribeLabelsStream { const NSID: &'static str = "com.atproto.label.subscribeLabels"; const ENCODING: jacquard_common::xrpc::MessageEncoding = jacquard_common::xrpc::MessageEncoding::DagCbor; type Message<'de> = SubscribeLabelsMessage<'de>; type Error<'de> = SubscribeLabelsError<'de>; fn decode_message<'de>( bytes: &'de [u8], ) -> Result, jacquard_common::error::DecodeError> { SubscribeLabelsMessage::decode_framed(bytes) } } impl jacquard_common::xrpc::XrpcSubscription for SubscribeLabels { const NSID: &'static str = "com.atproto.label.subscribeLabels"; const ENCODING: jacquard_common::xrpc::MessageEncoding = jacquard_common::xrpc::MessageEncoding::DagCbor; type Stream = SubscribeLabelsStream; } pub struct SubscribeLabelsEndpoint; impl jacquard_common::xrpc::SubscriptionEndpoint for SubscribeLabelsEndpoint { const PATH: &'static str = "/xrpc/com.atproto.label.subscribeLabels"; const ENCODING: jacquard_common::xrpc::MessageEncoding = jacquard_common::xrpc::MessageEncoding::DagCbor; type Params<'de> = SubscribeLabels; type Stream = SubscribeLabelsStream; }