#[allow(unused_imports)]
use alloc::collections::BTreeMap;
use crate::app_bsky::feed::BlockedPost;
use crate::app_bsky::feed::NotFoundPost;
use crate::app_bsky::feed::ThreadViewPost;
use crate::app_bsky::feed::ThreadgateView;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::AtUri;
use jacquard_common::types::value::Data;
use jacquard_common::{BosStr, CowStr, DefaultStr, FromStaticStr};
use jacquard_derive::{IntoStatic, open_union};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct GetPostThread<S: BosStr = DefaultStr> {
#[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>,
pub uri: AtUri<S>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct GetPostThreadOutput<S: BosStr = DefaultStr> {
pub thread: GetPostThreadOutputThread<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub threadgate: Option<ThreadgateView<S>>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum GetPostThreadOutputThread<S: BosStr = DefaultStr> {
#[serde(rename = "app.bsky.feed.defs#threadViewPost")]
ThreadViewPost(Box<ThreadViewPost<S>>),
#[serde(rename = "app.bsky.feed.defs#notFoundPost")]
NotFoundPost(Box<NotFoundPost<S>>),
#[serde(rename = "app.bsky.feed.defs#blockedPost")]
BlockedPost(Box<BlockedPost<S>>),
}
#[derive(
Serialize, Deserialize, Debug, Clone, PartialEq, Eq, thiserror::Error, miette::Diagnostic,
)]
#[serde(tag = "error", content = "message")]
pub enum GetPostThreadError {
#[serde(rename = "NotFound")]
NotFound(Option<SmolStr>),
#[serde(untagged)]
Other {
error: SmolStr,
message: Option<SmolStr>,
},
}
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::Other { error, message } => {
write!(f, "{}", error)?;
if let Some(msg) = message {
write!(f, ": {}", msg)?;
}
Ok(())
}
}
}
}
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<S: BosStr> = GetPostThreadOutput<S>;
type Err = GetPostThreadError;
}
impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for GetPostThread<S> {
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<S: BosStr> = GetPostThread<S>;
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::{IsSet, IsUnset, Set, Unset};
#[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<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetUri<St> {}
impl<St: State> State for SetUri<St> {
type Uri = Set<members::uri>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct uri(());
}
}
pub struct GetPostThreadBuilder<S: BosStr, St: get_post_thread_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<i64>, Option<i64>, Option<AtUri<S>>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> GetPostThread<S> {
pub fn new() -> GetPostThreadBuilder<S, get_post_thread_state::Empty> {
GetPostThreadBuilder::new()
}
}
impl<S: BosStr> GetPostThreadBuilder<S, get_post_thread_state::Empty> {
pub fn new() -> Self {
GetPostThreadBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: get_post_thread_state::State> GetPostThreadBuilder<S, St> {
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<S: BosStr, St: get_post_thread_state::State> GetPostThreadBuilder<S, St> {
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<S: BosStr, St> GetPostThreadBuilder<S, St>
where
St: get_post_thread_state::State,
St::Uri: get_post_thread_state::IsUnset,
{
pub fn uri(
mut self,
value: impl Into<AtUri<S>>,
) -> GetPostThreadBuilder<S, get_post_thread_state::SetUri<St>> {
self._fields.2 = Option::Some(value.into());
GetPostThreadBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> GetPostThreadBuilder<S, St>
where
St: get_post_thread_state::State,
St::Uri: get_post_thread_state::IsSet,
{
pub fn build(self) -> GetPostThread<S> {
GetPostThread {
depth: self._fields.0,
parent_height: self._fields.1,
uri: self._fields.2.unwrap(),
}
}
}