#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;
use jacquard_common::types::string::AtUri;
use jacquard_derive::{IntoStatic, lexicon, open_union};
use serde::{Serialize, Deserialize};
use crate::app_bsky::feed::BlockedPost;
use crate::app_bsky::feed::NotFoundPost;
use crate::app_bsky::feed::ThreadViewPost;
use crate::app_bsky::feed::ThreadgateView;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetPostThread<'a> {
#[serde(default = "_default_depth")]
#[serde(skip_serializing_if = "Option::is_none")]
pub depth: Option<i64>,
#[serde(default = "_default_parent_height")]
#[serde(skip_serializing_if = "Option::is_none")]
pub parent_height: Option<i64>,
#[serde(borrow)]
pub uri: AtUri<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetPostThreadOutput<'a> {
#[serde(borrow)]
pub thread: GetPostThreadOutputThread<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub threadgate: Option<ThreadgateView<'a>>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "'de: 'a"))]
pub enum GetPostThreadOutputThread<'a> {
#[serde(rename = "app.bsky.feed.defs#threadViewPost")]
ThreadViewPost(Box<ThreadViewPost<'a>>),
#[serde(rename = "app.bsky.feed.defs#notFoundPost")]
NotFoundPost(Box<NotFoundPost<'a>>),
#[serde(rename = "app.bsky.feed.defs#blockedPost")]
BlockedPost(Box<BlockedPost<'a>>),
}
#[open_union]
#[derive(
Serialize,
Deserialize,
Debug,
Clone,
PartialEq,
Eq,
thiserror::Error,
miette::Diagnostic,
IntoStatic
)]
#[serde(tag = "error", content = "message")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum GetPostThreadError<'a> {
#[serde(rename = "NotFound")]
NotFound(Option<CowStr<'a>>),
}
impl core::fmt::Display for GetPostThreadError<'_> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::NotFound(msg) => {
write!(f, "NotFound")?;
if let Some(msg) = msg {
write!(f, ": {}", msg)?;
}
Ok(())
}
Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
}
}
}
pub struct GetPostThreadResponse;
impl jacquard_common::xrpc::XrpcResp for GetPostThreadResponse {
const NSID: &'static str = "app.bsky.feed.getPostThread";
const ENCODING: &'static str = "application/json";
type Output<'de> = GetPostThreadOutput<'de>;
type Err<'de> = GetPostThreadError<'de>;
}
impl<'a> jacquard_common::xrpc::XrpcRequest for GetPostThread<'a> {
const NSID: &'static str = "app.bsky.feed.getPostThread";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Response = GetPostThreadResponse;
}
pub struct GetPostThreadRequest;
impl jacquard_common::xrpc::XrpcEndpoint for GetPostThreadRequest {
const PATH: &'static str = "/xrpc/app.bsky.feed.getPostThread";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Request<'de> = GetPostThread<'de>;
type Response = GetPostThreadResponse;
}
fn _default_depth() -> Option<i64> {
Some(6i64)
}
fn _default_parent_height() -> Option<i64> {
Some(80i64)
}
pub mod get_post_thread_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 Uri;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Uri = Unset;
}
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 Uri = Set<members::uri>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct uri(());
}
}
pub struct GetPostThreadBuilder<'a, S: get_post_thread_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<i64>, Option<i64>, Option<AtUri<'a>>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> GetPostThread<'a> {
pub fn new() -> GetPostThreadBuilder<'a, get_post_thread_state::Empty> {
GetPostThreadBuilder::new()
}
}
impl<'a> GetPostThreadBuilder<'a, get_post_thread_state::Empty> {
pub fn new() -> Self {
GetPostThreadBuilder {
_state: PhantomData,
_fields: (None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S: get_post_thread_state::State> GetPostThreadBuilder<'a, S> {
pub fn depth(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_depth(mut self, value: Option<i64>) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S: get_post_thread_state::State> GetPostThreadBuilder<'a, S> {
pub fn parent_height(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_parent_height(mut self, value: Option<i64>) -> Self {
self._fields.1 = value;
self
}
}
impl<'a, S> GetPostThreadBuilder<'a, S>
where
S: get_post_thread_state::State,
S::Uri: get_post_thread_state::IsUnset,
{
pub fn uri(
mut self,
value: impl Into<AtUri<'a>>,
) -> GetPostThreadBuilder<'a, get_post_thread_state::SetUri<S>> {
self._fields.2 = Option::Some(value.into());
GetPostThreadBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> GetPostThreadBuilder<'a, S>
where
S: get_post_thread_state::State,
S::Uri: get_post_thread_state::IsSet,
{
pub fn build(self) -> GetPostThread<'a> {
GetPostThread {
depth: self._fields.0,
parent_height: self._fields.1,
uri: self._fields.2.unwrap(),
}
}
}