jacquard_api/app_bsky/feed/
get_post_thread.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: app.bsky.feed.getPostThread
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[derive(
9    serde::Serialize,
10    serde::Deserialize,
11    Debug,
12    Clone,
13    PartialEq,
14    Eq,
15    bon::Builder
16)]
17#[builder(start_fn = new)]
18#[serde(rename_all = "camelCase")]
19pub struct GetPostThread<'a> {
20    ///(default: 6, min: 0, max: 1000)
21    #[serde(skip_serializing_if = "std::option::Option::is_none")]
22    pub depth: std::option::Option<i64>,
23    ///(default: 80, min: 0, max: 1000)
24    #[serde(skip_serializing_if = "std::option::Option::is_none")]
25    pub parent_height: std::option::Option<i64>,
26    #[serde(borrow)]
27    pub uri: jacquard_common::types::string::AtUri<'a>,
28}
29
30impl jacquard_common::IntoStatic for GetPostThread<'_> {
31    type Output = GetPostThread<'static>;
32    fn into_static(self) -> Self::Output {
33        GetPostThread {
34            depth: self.depth.into_static(),
35            parent_height: self.parent_height.into_static(),
36            uri: self.uri.into_static(),
37        }
38    }
39}
40
41#[jacquard_derive::lexicon]
42#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
43#[serde(rename_all = "camelCase")]
44pub struct GetPostThreadOutput<'a> {
45    #[serde(borrow)]
46    pub thread: GetPostThreadOutputRecordThread<'a>,
47    #[serde(skip_serializing_if = "std::option::Option::is_none")]
48    #[serde(borrow)]
49    pub threadgate: std::option::Option<crate::app_bsky::feed::ThreadgateView<'a>>,
50}
51
52#[jacquard_derive::open_union]
53#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
54#[serde(tag = "$type")]
55#[serde(bound(deserialize = "'de: 'a"))]
56pub enum GetPostThreadOutputRecordThread<'a> {
57    #[serde(rename = "app.bsky.feed.defs#threadViewPost")]
58    DefsThreadViewPost(Box<crate::app_bsky::feed::ThreadViewPost<'a>>),
59    #[serde(rename = "app.bsky.feed.defs#notFoundPost")]
60    DefsNotFoundPost(Box<crate::app_bsky::feed::NotFoundPost<'a>>),
61    #[serde(rename = "app.bsky.feed.defs#blockedPost")]
62    DefsBlockedPost(Box<crate::app_bsky::feed::BlockedPost<'a>>),
63}
64
65impl jacquard_common::IntoStatic for GetPostThreadOutputRecordThread<'_> {
66    type Output = GetPostThreadOutputRecordThread<'static>;
67    fn into_static(self) -> Self::Output {
68        match self {
69            GetPostThreadOutputRecordThread::DefsThreadViewPost(v) => {
70                GetPostThreadOutputRecordThread::DefsThreadViewPost(v.into_static())
71            }
72            GetPostThreadOutputRecordThread::DefsNotFoundPost(v) => {
73                GetPostThreadOutputRecordThread::DefsNotFoundPost(v.into_static())
74            }
75            GetPostThreadOutputRecordThread::DefsBlockedPost(v) => {
76                GetPostThreadOutputRecordThread::DefsBlockedPost(v.into_static())
77            }
78            GetPostThreadOutputRecordThread::Unknown(v) => {
79                GetPostThreadOutputRecordThread::Unknown(v.into_static())
80            }
81        }
82    }
83}
84
85impl jacquard_common::IntoStatic for GetPostThreadOutput<'_> {
86    type Output = GetPostThreadOutput<'static>;
87    fn into_static(self) -> Self::Output {
88        GetPostThreadOutput {
89            thread: self.thread.into_static(),
90            threadgate: self.threadgate.into_static(),
91            extra_data: self.extra_data.into_static(),
92        }
93    }
94}
95
96#[jacquard_derive::open_union]
97#[derive(
98    serde::Serialize,
99    serde::Deserialize,
100    Debug,
101    Clone,
102    PartialEq,
103    Eq,
104    thiserror::Error,
105    miette::Diagnostic
106)]
107#[serde(tag = "error", content = "message")]
108#[serde(bound(deserialize = "'de: 'a"))]
109pub enum GetPostThreadError<'a> {
110    #[serde(rename = "NotFound")]
111    NotFound(std::option::Option<String>),
112}
113
114impl std::fmt::Display for GetPostThreadError<'_> {
115    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
116        match self {
117            Self::NotFound(msg) => {
118                write!(f, "NotFound")?;
119                if let Some(msg) = msg {
120                    write!(f, ": {}", msg)?;
121                }
122                Ok(())
123            }
124            Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
125        }
126    }
127}
128
129impl jacquard_common::IntoStatic for GetPostThreadError<'_> {
130    type Output = GetPostThreadError<'static>;
131    fn into_static(self) -> Self::Output {
132        match self {
133            GetPostThreadError::NotFound(v) => {
134                GetPostThreadError::NotFound(v.into_static())
135            }
136            GetPostThreadError::Unknown(v) => {
137                GetPostThreadError::Unknown(v.into_static())
138            }
139        }
140    }
141}
142
143impl jacquard_common::types::xrpc::XrpcRequest for GetPostThread<'_> {
144    const NSID: &'static str = "app.bsky.feed.getPostThread";
145    const METHOD: jacquard_common::types::xrpc::XrpcMethod = jacquard_common::types::xrpc::XrpcMethod::Query;
146    const OUTPUT_ENCODING: &'static str = "application/json";
147    type Output<'de> = GetPostThreadOutput<'de>;
148    type Err<'de> = GetPostThreadError<'de>;
149}