#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::string::AtUri;
use jacquard_derive::{IntoStatic, lexicon, open_union};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::app_bsky::feed::ThreadgateView;
use crate::app_bsky::unspecced::ThreadItemBlocked;
use crate::app_bsky::unspecced::ThreadItemNoUnauthenticated;
use crate::app_bsky::unspecced::ThreadItemNotFound;
use crate::app_bsky::unspecced::ThreadItemPost;
use crate::app_bsky::unspecced::get_post_thread_v2;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetPostThreadV2<'a> {
#[serde(default = "_default_above")]
#[serde(skip_serializing_if = "Option::is_none")]
pub above: Option<bool>,
#[serde(borrow)]
pub anchor: AtUri<'a>,
#[serde(default = "_default_below")]
#[serde(skip_serializing_if = "Option::is_none")]
pub below: Option<i64>,
#[serde(default = "_default_branching_factor")]
#[serde(skip_serializing_if = "Option::is_none")]
pub branching_factor: Option<i64>,
#[serde(default = "_default_sort")]
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub sort: Option<CowStr<'a>>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetPostThreadV2Output<'a> {
pub has_other_replies: bool,
#[serde(borrow)]
pub thread: Vec<get_post_thread_v2::ThreadItem<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub threadgate: Option<ThreadgateView<'a>>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ThreadItem<'a> {
pub depth: i64,
#[serde(borrow)]
pub uri: AtUri<'a>,
#[serde(borrow)]
pub value: ThreadItemValue<'a>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "'de: 'a"))]
pub enum ThreadItemValue<'a> {
#[serde(rename = "app.bsky.unspecced.defs#threadItemPost")]
ThreadItemPost(Box<ThreadItemPost<'a>>),
#[serde(rename = "app.bsky.unspecced.defs#threadItemNoUnauthenticated")]
ThreadItemNoUnauthenticated(Box<ThreadItemNoUnauthenticated<'a>>),
#[serde(rename = "app.bsky.unspecced.defs#threadItemNotFound")]
ThreadItemNotFound(Box<ThreadItemNotFound<'a>>),
#[serde(rename = "app.bsky.unspecced.defs#threadItemBlocked")]
ThreadItemBlocked(Box<ThreadItemBlocked<'a>>),
}
pub struct GetPostThreadV2Response;
impl jacquard_common::xrpc::XrpcResp for GetPostThreadV2Response {
const NSID: &'static str = "app.bsky.unspecced.getPostThreadV2";
const ENCODING: &'static str = "application/json";
type Output<'de> = GetPostThreadV2Output<'de>;
type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}
impl<'a> jacquard_common::xrpc::XrpcRequest for GetPostThreadV2<'a> {
const NSID: &'static str = "app.bsky.unspecced.getPostThreadV2";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Response = GetPostThreadV2Response;
}
pub struct GetPostThreadV2Request;
impl jacquard_common::xrpc::XrpcEndpoint for GetPostThreadV2Request {
const PATH: &'static str = "/xrpc/app.bsky.unspecced.getPostThreadV2";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Request<'de> = GetPostThreadV2<'de>;
type Response = GetPostThreadV2Response;
}
impl<'a> LexiconSchema for ThreadItem<'a> {
fn nsid() -> &'static str {
"app.bsky.unspecced.getPostThreadV2"
}
fn def_name() -> &'static str {
"threadItem"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_bsky_unspecced_getPostThreadV2()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
fn _default_above() -> Option<bool> {
Some(true)
}
fn _default_below() -> Option<i64> {
Some(6i64)
}
fn _default_branching_factor() -> Option<i64> {
Some(10i64)
}
fn _default_sort() -> Option<CowStr<'static>> {
Some(CowStr::from("oldest"))
}
pub mod get_post_thread_v2_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 Anchor;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Anchor = Unset;
}
pub struct SetAnchor<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetAnchor<S> {}
impl<S: State> State for SetAnchor<S> {
type Anchor = Set<members::anchor>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct anchor(());
}
}
pub struct GetPostThreadV2Builder<'a, S: get_post_thread_v2_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<bool>,
Option<AtUri<'a>>,
Option<i64>,
Option<i64>,
Option<CowStr<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> GetPostThreadV2<'a> {
pub fn new() -> GetPostThreadV2Builder<'a, get_post_thread_v2_state::Empty> {
GetPostThreadV2Builder::new()
}
}
impl<'a> GetPostThreadV2Builder<'a, get_post_thread_v2_state::Empty> {
pub fn new() -> Self {
GetPostThreadV2Builder {
_state: PhantomData,
_fields: (None, None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S: get_post_thread_v2_state::State> GetPostThreadV2Builder<'a, S> {
pub fn above(mut self, value: impl Into<Option<bool>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_above(mut self, value: Option<bool>) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S> GetPostThreadV2Builder<'a, S>
where
S: get_post_thread_v2_state::State,
S::Anchor: get_post_thread_v2_state::IsUnset,
{
pub fn anchor(
mut self,
value: impl Into<AtUri<'a>>,
) -> GetPostThreadV2Builder<'a, get_post_thread_v2_state::SetAnchor<S>> {
self._fields.1 = Option::Some(value.into());
GetPostThreadV2Builder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: get_post_thread_v2_state::State> GetPostThreadV2Builder<'a, S> {
pub fn below(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_below(mut self, value: Option<i64>) -> Self {
self._fields.2 = value;
self
}
}
impl<'a, S: get_post_thread_v2_state::State> GetPostThreadV2Builder<'a, S> {
pub fn branching_factor(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_branching_factor(mut self, value: Option<i64>) -> Self {
self._fields.3 = value;
self
}
}
impl<'a, S: get_post_thread_v2_state::State> GetPostThreadV2Builder<'a, S> {
pub fn sort(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_sort(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.4 = value;
self
}
}
impl<'a, S> GetPostThreadV2Builder<'a, S>
where
S: get_post_thread_v2_state::State,
S::Anchor: get_post_thread_v2_state::IsSet,
{
pub fn build(self) -> GetPostThreadV2<'a> {
GetPostThreadV2 {
above: self._fields.0,
anchor: self._fields.1.unwrap(),
below: self._fields.2,
branching_factor: self._fields.3,
sort: self._fields.4,
}
}
}
pub mod thread_item_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 Value;
type Depth;
type Uri;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Value = Unset;
type Depth = Unset;
type Uri = Unset;
}
pub struct SetValue<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetValue<S> {}
impl<S: State> State for SetValue<S> {
type Value = Set<members::value>;
type Depth = S::Depth;
type Uri = S::Uri;
}
pub struct SetDepth<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetDepth<S> {}
impl<S: State> State for SetDepth<S> {
type Value = S::Value;
type Depth = Set<members::depth>;
type Uri = S::Uri;
}
pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetUri<S> {}
impl<S: State> State for SetUri<S> {
type Value = S::Value;
type Depth = S::Depth;
type Uri = Set<members::uri>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct value(());
pub struct depth(());
pub struct uri(());
}
}
pub struct ThreadItemBuilder<'a, S: thread_item_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<i64>, Option<AtUri<'a>>, Option<ThreadItemValue<'a>>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> ThreadItem<'a> {
pub fn new() -> ThreadItemBuilder<'a, thread_item_state::Empty> {
ThreadItemBuilder::new()
}
}
impl<'a> ThreadItemBuilder<'a, thread_item_state::Empty> {
pub fn new() -> Self {
ThreadItemBuilder {
_state: PhantomData,
_fields: (None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> ThreadItemBuilder<'a, S>
where
S: thread_item_state::State,
S::Depth: thread_item_state::IsUnset,
{
pub fn depth(
mut self,
value: impl Into<i64>,
) -> ThreadItemBuilder<'a, thread_item_state::SetDepth<S>> {
self._fields.0 = Option::Some(value.into());
ThreadItemBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ThreadItemBuilder<'a, S>
where
S: thread_item_state::State,
S::Uri: thread_item_state::IsUnset,
{
pub fn uri(
mut self,
value: impl Into<AtUri<'a>>,
) -> ThreadItemBuilder<'a, thread_item_state::SetUri<S>> {
self._fields.1 = Option::Some(value.into());
ThreadItemBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ThreadItemBuilder<'a, S>
where
S: thread_item_state::State,
S::Value: thread_item_state::IsUnset,
{
pub fn value(
mut self,
value: impl Into<ThreadItemValue<'a>>,
) -> ThreadItemBuilder<'a, thread_item_state::SetValue<S>> {
self._fields.2 = Option::Some(value.into());
ThreadItemBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ThreadItemBuilder<'a, S>
where
S: thread_item_state::State,
S::Value: thread_item_state::IsSet,
S::Depth: thread_item_state::IsSet,
S::Uri: thread_item_state::IsSet,
{
pub fn build(self) -> ThreadItem<'a> {
ThreadItem {
depth: self._fields.0.unwrap(),
uri: self._fields.1.unwrap(),
value: self._fields.2.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> ThreadItem<'a> {
ThreadItem {
depth: self._fields.0.unwrap(),
uri: self._fields.1.unwrap(),
value: self._fields.2.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_app_bsky_unspecced_getPostThreadV2() -> LexiconDoc<'static> {
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
use alloc::collections::BTreeMap;
LexiconDoc {
lexicon: Lexicon::Lexicon1,
id: CowStr::new_static("app.bsky.unspecced.getPostThreadV2"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("main"),
LexUserType::XrpcQuery(LexXrpcQuery {
parameters: Some(
LexXrpcQueryParameter::Params(LexXrpcParameters {
required: Some(vec![SmolStr::new_static("anchor")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("above"),
LexXrpcParametersProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("anchor"),
LexXrpcParametersProperty::String(LexString {
description: Some(
CowStr::new_static(
"Reference (AT-URI) to post record. This is the anchor post, and the thread will be built around it. It can be any post in the tree, not necessarily a root post.",
),
),
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("below"),
LexXrpcParametersProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("branchingFactor"),
LexXrpcParametersProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("sort"),
LexXrpcParametersProperty::String(LexString {
description: Some(
CowStr::new_static("Sorting for the thread replies."),
),
..Default::default()
}),
);
map
},
..Default::default()
}),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("threadItem"),
LexUserType::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("uri"), SmolStr::new_static("depth"),
SmolStr::new_static("value")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("depth"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("uri"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("value"),
LexObjectProperty::Union(LexRefUnion {
refs: vec![
CowStr::new_static("app.bsky.unspecced.defs#threadItemPost"),
CowStr::new_static("app.bsky.unspecced.defs#threadItemNoUnauthenticated"),
CowStr::new_static("app.bsky.unspecced.defs#threadItemNotFound"),
CowStr::new_static("app.bsky.unspecced.defs#threadItemBlocked")
],
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}