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