jacquard_api/app_bsky/feed/
get_posts.rs1#[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
36pub 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
53pub 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 pub trait State: sealed::Sealed {
74 type Uris;
75 }
76 pub struct Empty(());
78 impl sealed::Sealed for Empty {}
79 impl State for Empty {
80 type Uris = Unset;
81 }
82 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 #[allow(non_camel_case_types)]
90 pub mod members {
91 pub struct uris(());
93 }
94}
95
96pub 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 pub fn new() -> GetPostsBuilder<get_posts_state::Empty, DefaultStr> {
106 GetPostsBuilder::new()
107 }
108}
109
110impl<S: BosStr> GetPosts<S> {
111 pub fn builder() -> GetPostsBuilder<get_posts_state::Empty, S> {
113 GetPostsBuilder::builder()
114 }
115}
116
117impl GetPostsBuilder<get_posts_state::Empty, DefaultStr> {
118 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 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 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 pub fn build(self) -> GetPosts<S> {
165 GetPosts {
166 uris: self._fields.0.unwrap(),
167 }
168 }
169}