Skip to main content

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#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::CowStr;
14use jacquard_common::types::string::AtUri;
15use jacquard_derive::{IntoStatic, lexicon, open_union};
16use serde::{Serialize, Deserialize};
17use crate::app_bsky::feed::BlockedPost;
18use crate::app_bsky::feed::NotFoundPost;
19use crate::app_bsky::feed::ThreadViewPost;
20use crate::app_bsky::feed::ThreadgateView;
21
22#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
23#[serde(rename_all = "camelCase")]
24pub struct GetPostThread<'a> {
25    ///Defaults to `6`. Min: 0. Max: 1000.
26    #[serde(default = "_default_depth")]
27    #[serde(skip_serializing_if = "Option::is_none")]
28    pub depth: Option<i64>,
29    ///Defaults to `80`. Min: 0. Max: 1000.
30    #[serde(default = "_default_parent_height")]
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub parent_height: Option<i64>,
33    #[serde(borrow)]
34    pub uri: AtUri<'a>,
35}
36
37
38#[lexicon]
39#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
40#[serde(rename_all = "camelCase")]
41pub struct GetPostThreadOutput<'a> {
42    #[serde(borrow)]
43    pub thread: GetPostThreadOutputThread<'a>,
44    #[serde(skip_serializing_if = "Option::is_none")]
45    #[serde(borrow)]
46    pub threadgate: Option<ThreadgateView<'a>>,
47}
48
49
50#[open_union]
51#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
52#[serde(tag = "$type", bound(deserialize = "'de: 'a"))]
53pub enum GetPostThreadOutputThread<'a> {
54    #[serde(rename = "app.bsky.feed.defs#threadViewPost")]
55    ThreadViewPost(Box<ThreadViewPost<'a>>),
56    #[serde(rename = "app.bsky.feed.defs#notFoundPost")]
57    NotFoundPost(Box<NotFoundPost<'a>>),
58    #[serde(rename = "app.bsky.feed.defs#blockedPost")]
59    BlockedPost(Box<BlockedPost<'a>>),
60}
61
62
63#[open_union]
64#[derive(
65    Serialize,
66    Deserialize,
67    Debug,
68    Clone,
69    PartialEq,
70    Eq,
71    thiserror::Error,
72    miette::Diagnostic,
73    IntoStatic
74)]
75
76#[serde(tag = "error", content = "message")]
77#[serde(bound(deserialize = "'de: 'a"))]
78pub enum GetPostThreadError<'a> {
79    #[serde(rename = "NotFound")]
80    NotFound(Option<CowStr<'a>>),
81}
82
83impl core::fmt::Display for GetPostThreadError<'_> {
84    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
85        match self {
86            Self::NotFound(msg) => {
87                write!(f, "NotFound")?;
88                if let Some(msg) = msg {
89                    write!(f, ": {}", msg)?;
90                }
91                Ok(())
92            }
93            Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
94        }
95    }
96}
97
98/// Response type for app.bsky.feed.getPostThread
99pub struct GetPostThreadResponse;
100impl jacquard_common::xrpc::XrpcResp for GetPostThreadResponse {
101    const NSID: &'static str = "app.bsky.feed.getPostThread";
102    const ENCODING: &'static str = "application/json";
103    type Output<'de> = GetPostThreadOutput<'de>;
104    type Err<'de> = GetPostThreadError<'de>;
105}
106
107impl<'a> jacquard_common::xrpc::XrpcRequest for GetPostThread<'a> {
108    const NSID: &'static str = "app.bsky.feed.getPostThread";
109    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
110    type Response = GetPostThreadResponse;
111}
112
113/// Endpoint type for app.bsky.feed.getPostThread
114pub struct GetPostThreadRequest;
115impl jacquard_common::xrpc::XrpcEndpoint for GetPostThreadRequest {
116    const PATH: &'static str = "/xrpc/app.bsky.feed.getPostThread";
117    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
118    type Request<'de> = GetPostThread<'de>;
119    type Response = GetPostThreadResponse;
120}
121
122fn _default_depth() -> Option<i64> {
123    Some(6i64)
124}
125
126fn _default_parent_height() -> Option<i64> {
127    Some(80i64)
128}
129
130pub mod get_post_thread_state {
131
132    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
133    #[allow(unused)]
134    use ::core::marker::PhantomData;
135    mod sealed {
136        pub trait Sealed {}
137    }
138    /// State trait tracking which required fields have been set
139    pub trait State: sealed::Sealed {
140        type Uri;
141    }
142    /// Empty state - all required fields are unset
143    pub struct Empty(());
144    impl sealed::Sealed for Empty {}
145    impl State for Empty {
146        type Uri = Unset;
147    }
148    ///State transition - sets the `uri` field to Set
149    pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
150    impl<S: State> sealed::Sealed for SetUri<S> {}
151    impl<S: State> State for SetUri<S> {
152        type Uri = Set<members::uri>;
153    }
154    /// Marker types for field names
155    #[allow(non_camel_case_types)]
156    pub mod members {
157        ///Marker type for the `uri` field
158        pub struct uri(());
159    }
160}
161
162/// Builder for constructing an instance of this type
163pub struct GetPostThreadBuilder<'a, S: get_post_thread_state::State> {
164    _state: PhantomData<fn() -> S>,
165    _fields: (Option<i64>, Option<i64>, Option<AtUri<'a>>),
166    _lifetime: PhantomData<&'a ()>,
167}
168
169impl<'a> GetPostThread<'a> {
170    /// Create a new builder for this type
171    pub fn new() -> GetPostThreadBuilder<'a, get_post_thread_state::Empty> {
172        GetPostThreadBuilder::new()
173    }
174}
175
176impl<'a> GetPostThreadBuilder<'a, get_post_thread_state::Empty> {
177    /// Create a new builder with all fields unset
178    pub fn new() -> Self {
179        GetPostThreadBuilder {
180            _state: PhantomData,
181            _fields: (None, None, None),
182            _lifetime: PhantomData,
183        }
184    }
185}
186
187impl<'a, S: get_post_thread_state::State> GetPostThreadBuilder<'a, S> {
188    /// Set the `depth` field (optional)
189    pub fn depth(mut self, value: impl Into<Option<i64>>) -> Self {
190        self._fields.0 = value.into();
191        self
192    }
193    /// Set the `depth` field to an Option value (optional)
194    pub fn maybe_depth(mut self, value: Option<i64>) -> Self {
195        self._fields.0 = value;
196        self
197    }
198}
199
200impl<'a, S: get_post_thread_state::State> GetPostThreadBuilder<'a, S> {
201    /// Set the `parentHeight` field (optional)
202    pub fn parent_height(mut self, value: impl Into<Option<i64>>) -> Self {
203        self._fields.1 = value.into();
204        self
205    }
206    /// Set the `parentHeight` field to an Option value (optional)
207    pub fn maybe_parent_height(mut self, value: Option<i64>) -> Self {
208        self._fields.1 = value;
209        self
210    }
211}
212
213impl<'a, S> GetPostThreadBuilder<'a, S>
214where
215    S: get_post_thread_state::State,
216    S::Uri: get_post_thread_state::IsUnset,
217{
218    /// Set the `uri` field (required)
219    pub fn uri(
220        mut self,
221        value: impl Into<AtUri<'a>>,
222    ) -> GetPostThreadBuilder<'a, get_post_thread_state::SetUri<S>> {
223        self._fields.2 = Option::Some(value.into());
224        GetPostThreadBuilder {
225            _state: PhantomData,
226            _fields: self._fields,
227            _lifetime: PhantomData,
228        }
229    }
230}
231
232impl<'a, S> GetPostThreadBuilder<'a, S>
233where
234    S: get_post_thread_state::State,
235    S::Uri: get_post_thread_state::IsSet,
236{
237    /// Build the final struct
238    pub fn build(self) -> GetPostThread<'a> {
239        GetPostThread {
240            depth: self._fields.0,
241            parent_height: self._fields.1,
242            uri: self._fields.2.unwrap(),
243        }
244    }
245}