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