Skip to main content

jacquard_api/app_bsky/feed/
get_posts.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: app.bsky.feed.getPosts
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::{BosStr, DefaultStr, FromStaticStr};
14use jacquard_common::deps::smol_str::SmolStr;
15use jacquard_common::types::string::AtUri;
16use jacquard_common::types::value::Data;
17use jacquard_derive::IntoStatic;
18use serde::{Serialize, Deserialize};
19use crate::app_bsky::feed::PostView;
20
21#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
22#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
23pub struct GetPosts<S: BosStr = DefaultStr> {
24    pub uris: Vec<AtUri<S>>,
25}
26
27
28#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
29#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
30pub struct GetPostsOutput<S: BosStr = DefaultStr> {
31    pub posts: Vec<PostView<S>>,
32    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
33    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
34}
35
36/** Response marker for the `app.bsky.feed.getPosts` query.
37
38Implements `jacquard_common::xrpc::XrpcResp`; successful bodies decode as `Self::Output<S>`, which is `GetPostsOutput<S>` for this endpoint.*/
39pub struct GetPostsResponse;
40impl jacquard_common::xrpc::XrpcResp for GetPostsResponse {
41    const NSID: &'static str = "app.bsky.feed.getPosts";
42    const ENCODING: &'static str = "application/json";
43    type Output<S: BosStr> = GetPostsOutput<S>;
44    type Err = jacquard_common::xrpc::GenericError;
45}
46
47impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for GetPosts<S> {
48    const NSID: &'static str = "app.bsky.feed.getPosts";
49    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
50    type Response = GetPostsResponse;
51}
52
53/** Endpoint marker for the `app.bsky.feed.getPosts` query.
54
55Path: `/xrpc/app.bsky.feed.getPosts`. The request payload type is `GetPosts<S>`; send that request with `jacquard::Client` or use this marker through lower-level `XrpcEndpoint` APIs.*/
56pub struct GetPostsRequest;
57impl jacquard_common::xrpc::XrpcEndpoint for GetPostsRequest {
58    const PATH: &'static str = "/xrpc/app.bsky.feed.getPosts";
59    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
60    type Request<S: BosStr> = GetPosts<S>;
61    type Response = GetPostsResponse;
62}
63
64pub mod get_posts_state {
65
66    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
67    #[allow(unused)]
68    use ::core::marker::PhantomData;
69    mod sealed {
70        pub trait Sealed {}
71    }
72    /// State trait tracking which required fields have been set
73    pub trait State: sealed::Sealed {
74        type Uris;
75    }
76    /// Empty state - all required fields are unset
77    pub struct Empty(());
78    impl sealed::Sealed for Empty {}
79    impl State for Empty {
80        type Uris = Unset;
81    }
82    ///State transition - sets the `uris` field to Set
83    pub struct SetUris<St: State = Empty>(PhantomData<fn() -> St>);
84    impl<St: State> sealed::Sealed for SetUris<St> {}
85    impl<St: State> State for SetUris<St> {
86        type Uris = Set<members::uris>;
87    }
88    /// Marker types for field names
89    #[allow(non_camel_case_types)]
90    pub mod members {
91        ///Marker type for the `uris` field
92        pub struct uris(());
93    }
94}
95
96/// Builder for constructing an instance of this type.
97pub struct GetPostsBuilder<St: get_posts_state::State, S: BosStr = DefaultStr> {
98    _state: PhantomData<fn() -> St>,
99    _fields: (Option<Vec<AtUri<S>>>,),
100    _type: PhantomData<fn() -> S>,
101}
102
103impl GetPosts<DefaultStr> {
104    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
105    pub fn new() -> GetPostsBuilder<get_posts_state::Empty, DefaultStr> {
106        GetPostsBuilder::new()
107    }
108}
109
110impl<S: BosStr> GetPosts<S> {
111    /// Create a new builder for this type
112    pub fn builder() -> GetPostsBuilder<get_posts_state::Empty, S> {
113        GetPostsBuilder::builder()
114    }
115}
116
117impl GetPostsBuilder<get_posts_state::Empty, DefaultStr> {
118    /// Create a new builder with all fields unset, using the default string type, if needed
119    pub fn new() -> Self {
120        GetPostsBuilder {
121            _state: PhantomData,
122            _fields: (None,),
123            _type: PhantomData,
124        }
125    }
126}
127
128impl<S: BosStr> GetPostsBuilder<get_posts_state::Empty, S> {
129    /// Create a new builder with all fields unset
130    pub fn builder() -> Self {
131        GetPostsBuilder {
132            _state: PhantomData,
133            _fields: (None,),
134            _type: PhantomData,
135        }
136    }
137}
138
139impl<St, S: BosStr> GetPostsBuilder<St, S>
140where
141    St: get_posts_state::State,
142    St::Uris: get_posts_state::IsUnset,
143{
144    /// Set the `uris` field (required)
145    pub fn uris(
146        mut self,
147        value: impl Into<Vec<AtUri<S>>>,
148    ) -> GetPostsBuilder<get_posts_state::SetUris<St>, S> {
149        self._fields.0 = Option::Some(value.into());
150        GetPostsBuilder {
151            _state: PhantomData,
152            _fields: self._fields,
153            _type: PhantomData,
154        }
155    }
156}
157
158impl<St, S: BosStr> GetPostsBuilder<St, S>
159where
160    St: get_posts_state::State,
161    St::Uris: get_posts_state::IsSet,
162{
163    /// Build the final struct.
164    pub fn build(self) -> GetPosts<S> {
165        GetPosts {
166            uris: self._fields.0.unwrap(),
167        }
168    }
169}