jacquard_api/app_bsky/feed/
get_posts.rs1#[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
41pub 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
58pub 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 pub trait State: sealed::Sealed {
79 type Uris;
80 }
81 pub struct Empty(());
83 impl sealed::Sealed for Empty {}
84 impl State for Empty {
85 type Uris = Unset;
86 }
87 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 #[allow(non_camel_case_types)]
95 pub mod members {
96 pub struct uris(());
98 }
99}
100
101pub 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 pub fn new() -> GetPostsBuilder<get_posts_state::Empty, DefaultStr> {
111 GetPostsBuilder::new()
112 }
113}
114
115impl<S: BosStr> GetPosts<S> {
116 pub fn builder() -> GetPostsBuilder<get_posts_state::Empty, S> {
118 GetPostsBuilder::builder()
119 }
120}
121
122impl GetPostsBuilder<get_posts_state::Empty, DefaultStr> {
123 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 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 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 pub fn build(self) -> GetPosts<S> {
170 GetPosts {
171 uris: self._fields.0.unwrap(),
172 }
173 }
174}