#[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<jacquard_common::CowStr<'a>>,
#[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<String> 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<str> for InfoName<'a> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<'a> serde::Serialize for InfoName<'a> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, 'a> serde::Deserialize<'de> for InfoName<'a>
where
'de: 'a,
{
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
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::deps::smol_str::SmolStr::new_static("info"),
::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
description: None,
required: Some(
vec![
::jacquard_common::deps::smol_str::SmolStr::new_static("name")
],
),
nullable: None,
properties: {
#[allow(unused_mut)]
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::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::deps::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::deps::smol_str::SmolStr::new_static("labels"),
::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
description: None,
required: Some(
vec![
::jacquard_common::deps::smol_str::SmolStr::new_static("seq"),
::jacquard_common::deps::smol_str::SmolStr::new_static("labels")
],
),
nullable: None,
properties: {
#[allow(unused_mut)]
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::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::deps::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::deps::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::deps::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<crate::com_atproto::label::Label<'a>>,
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 {}
}
pub trait State: sealed::Sealed {
type Seq;
type Labels;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Seq = Unset;
type Labels = Unset;
}
pub struct SetSeq<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetSeq<S> {}
impl<S: State> State for SetSeq<S> {
type Seq = Set<members::seq>;
type Labels = S::Labels;
}
pub struct SetLabels<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetLabels<S> {}
impl<S: State> State for SetLabels<S> {
type Seq = S::Seq;
type Labels = Set<members::labels>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct seq(());
pub struct labels(());
}
}
pub struct LabelsBuilder<'a, S: labels_state::State> {
_phantom_state: ::core::marker::PhantomData<fn() -> S>,
__unsafe_private_named: (
::core::option::Option<Vec<crate::com_atproto::label::Label<'a>>>,
::core::option::Option<i64>,
),
_phantom: ::core::marker::PhantomData<&'a ()>,
}
impl<'a> Labels<'a> {
pub fn new() -> LabelsBuilder<'a, labels_state::Empty> {
LabelsBuilder::new()
}
}
impl<'a> LabelsBuilder<'a, labels_state::Empty> {
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,
{
pub fn labels(
mut self,
value: impl Into<Vec<crate::com_atproto::label::Label<'a>>>,
) -> LabelsBuilder<'a, labels_state::SetLabels<S>> {
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,
{
pub fn seq(
mut self,
value: impl Into<i64>,
) -> LabelsBuilder<'a, labels_state::SetSeq<S>> {
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::Seq: labels_state::IsSet,
S::Labels: labels_state::IsSet,
{
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(),
}
}
pub fn build_with_data(
self,
extra_data: std::collections::BTreeMap<
jacquard_common::deps::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<i64>,
}
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 {}
}
pub trait State: sealed::Sealed {}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {}
#[allow(non_camel_case_types)]
pub mod members {}
}
pub struct SubscribeLabelsBuilder<S: subscribe_labels_state::State> {
_phantom_state: ::core::marker::PhantomData<fn() -> S>,
__unsafe_private_named: (::core::option::Option<i64>,),
}
impl SubscribeLabels {
pub fn new() -> SubscribeLabelsBuilder<subscribe_labels_state::Empty> {
SubscribeLabelsBuilder::new()
}
}
impl SubscribeLabelsBuilder<subscribe_labels_state::Empty> {
pub fn new() -> Self {
SubscribeLabelsBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: (None,),
}
}
}
impl<S: subscribe_labels_state::State> SubscribeLabelsBuilder<S> {
pub fn cursor(mut self, value: impl Into<Option<i64>>) -> Self {
self.__unsafe_private_named.0 = value.into();
self
}
pub fn maybe_cursor(mut self, value: Option<i64>) -> Self {
self.__unsafe_private_named.0 = value;
self
}
}
impl<S> SubscribeLabelsBuilder<S>
where
S: subscribe_labels_state::State,
{
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<crate::com_atproto::label::subscribe_labels::Labels<'a>>),
#[serde(rename = "#info")]
Info(Box<crate::com_atproto::label::subscribe_labels::Info<'a>>),
}
impl<'a> SubscribeLabelsMessage<'a> {
pub fn decode_framed<'de: 'a>(
bytes: &'de [u8],
) -> Result<SubscribeLabelsMessage<'a>, jacquard_common::error::DecodeError> {
let (header, body) = jacquard_common::xrpc::subscription::parse_event_header(
bytes,
)?;
match header.t.as_str() {
"#labels" => {
let variant = jacquard_common::deps::codegen::serde_ipld_dagcbor::from_slice(
body,
)?;
Ok(Self::Labels(Box::new(variant)))
}
"#info" => {
let variant = jacquard_common::deps::codegen::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<jacquard_common::CowStr<'a>>),
}
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),
}
}
}
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<Self::Message<'de>, 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;
}