jacquard_api/app_bsky/graph/
get_list.rs1#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11use crate::app_bsky::graph::ListItemView;
12use crate::app_bsky::graph::ListView;
13#[allow(unused_imports)]
14use core::marker::PhantomData;
15use jacquard_common::deps::smol_str::SmolStr;
16use jacquard_common::types::string::AtUri;
17use jacquard_common::types::value::Data;
18use jacquard_common::{BosStr, CowStr, DefaultStr, FromStaticStr};
19use jacquard_derive::IntoStatic;
20use serde::{Deserialize, Serialize};
21
22#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
23#[serde(
24 rename_all = "camelCase",
25 bound(deserialize = "S: Deserialize<'de> + BosStr")
26)]
27pub struct GetList<S: BosStr = DefaultStr> {
28 #[serde(skip_serializing_if = "Option::is_none")]
29 pub cursor: Option<S>,
30 #[serde(default = "_default_limit")]
32 #[serde(skip_serializing_if = "Option::is_none")]
33 pub limit: Option<i64>,
34 pub list: AtUri<S>,
35}
36
37#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
38#[serde(
39 rename_all = "camelCase",
40 bound(deserialize = "S: Deserialize<'de> + BosStr")
41)]
42pub struct GetListOutput<S: BosStr = DefaultStr> {
43 #[serde(skip_serializing_if = "Option::is_none")]
44 pub cursor: Option<S>,
45 pub items: Vec<ListItemView<S>>,
46 pub list: ListView<S>,
47 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
48 pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
49}
50
51pub struct GetListResponse;
55impl jacquard_common::xrpc::XrpcResp for GetListResponse {
56 const NSID: &'static str = "app.bsky.graph.getList";
57 const ENCODING: &'static str = "application/json";
58 type Output<S: BosStr> = GetListOutput<S>;
59 type Err = jacquard_common::xrpc::GenericError;
60}
61
62impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for GetList<S> {
63 const NSID: &'static str = "app.bsky.graph.getList";
64 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
65 type Response = GetListResponse;
66}
67
68pub struct GetListRequest;
72impl jacquard_common::xrpc::XrpcEndpoint for GetListRequest {
73 const PATH: &'static str = "/xrpc/app.bsky.graph.getList";
74 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
75 type Request<S: BosStr> = GetList<S>;
76 type Response = GetListResponse;
77}
78
79fn _default_limit() -> Option<i64> {
80 Some(50i64)
81}
82
83pub mod get_list_state {
84
85 pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
86 #[allow(unused)]
87 use ::core::marker::PhantomData;
88 mod sealed {
89 pub trait Sealed {}
90 }
91 pub trait State: sealed::Sealed {
93 type List;
94 }
95 pub struct Empty(());
97 impl sealed::Sealed for Empty {}
98 impl State for Empty {
99 type List = Unset;
100 }
101 pub struct SetList<St: State = Empty>(PhantomData<fn() -> St>);
103 impl<St: State> sealed::Sealed for SetList<St> {}
104 impl<St: State> State for SetList<St> {
105 type List = Set<members::list>;
106 }
107 #[allow(non_camel_case_types)]
109 pub mod members {
110 pub struct list(());
112 }
113}
114
115pub struct GetListBuilder<St: get_list_state::State, S: BosStr = DefaultStr> {
117 _state: PhantomData<fn() -> St>,
118 _fields: (Option<S>, Option<i64>, Option<AtUri<S>>),
119 _type: PhantomData<fn() -> S>,
120}
121
122impl GetList<DefaultStr> {
123 pub fn new() -> GetListBuilder<get_list_state::Empty, DefaultStr> {
125 GetListBuilder::new()
126 }
127}
128
129impl<S: BosStr> GetList<S> {
130 pub fn builder() -> GetListBuilder<get_list_state::Empty, S> {
132 GetListBuilder::builder()
133 }
134}
135
136impl GetListBuilder<get_list_state::Empty, DefaultStr> {
137 pub fn new() -> Self {
139 GetListBuilder {
140 _state: PhantomData,
141 _fields: (None, None, None),
142 _type: PhantomData,
143 }
144 }
145}
146
147impl<S: BosStr> GetListBuilder<get_list_state::Empty, S> {
148 pub fn builder() -> Self {
150 GetListBuilder {
151 _state: PhantomData,
152 _fields: (None, None, None),
153 _type: PhantomData,
154 }
155 }
156}
157
158impl<St: get_list_state::State, S: BosStr> GetListBuilder<St, S> {
159 pub fn cursor(mut self, value: impl Into<Option<S>>) -> Self {
161 self._fields.0 = value.into();
162 self
163 }
164 pub fn maybe_cursor(mut self, value: Option<S>) -> Self {
166 self._fields.0 = value;
167 self
168 }
169}
170
171impl<St: get_list_state::State, S: BosStr> GetListBuilder<St, S> {
172 pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
174 self._fields.1 = value.into();
175 self
176 }
177 pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
179 self._fields.1 = value;
180 self
181 }
182}
183
184impl<St, S: BosStr> GetListBuilder<St, S>
185where
186 St: get_list_state::State,
187 St::List: get_list_state::IsUnset,
188{
189 pub fn list(
191 mut self,
192 value: impl Into<AtUri<S>>,
193 ) -> GetListBuilder<get_list_state::SetList<St>, S> {
194 self._fields.2 = Option::Some(value.into());
195 GetListBuilder {
196 _state: PhantomData,
197 _fields: self._fields,
198 _type: PhantomData,
199 }
200 }
201}
202
203impl<St, S: BosStr> GetListBuilder<St, S>
204where
205 St: get_list_state::State,
206 St::List: get_list_state::IsSet,
207{
208 pub fn build(self) -> GetList<S> {
210 GetList {
211 cursor: self._fields.0,
212 limit: self._fields.1,
213 list: self._fields.2.unwrap(),
214 }
215 }
216}