Skip to main content

jacquard_api/app_bsky/graph/
get_list.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: app.bsky.graph.getList
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::{CowStr, 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::graph::ListItemView;
20use crate::app_bsky::graph::ListView;
21
22#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
23#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
24pub struct GetList<S: BosStr = DefaultStr> {
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub cursor: Option<S>,
27    /// Defaults to `50`. Min: 1. Max: 100.
28    #[serde(default = "_default_limit")]
29    #[serde(skip_serializing_if = "Option::is_none")]
30    pub limit: Option<i64>,
31    pub list: AtUri<S>,
32}
33
34
35#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
36#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
37pub struct GetListOutput<S: BosStr = DefaultStr> {
38    #[serde(skip_serializing_if = "Option::is_none")]
39    pub cursor: Option<S>,
40    pub items: Vec<ListItemView<S>>,
41    pub list: ListView<S>,
42    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
43    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
44}
45
46/** Response marker for the `app.bsky.graph.getList` query.
47
48Implements `jacquard_common::xrpc::XrpcResp`; successful bodies decode as `Self::Output<S>`, which is `GetListOutput<S>` for this endpoint.*/
49pub struct GetListResponse;
50impl jacquard_common::xrpc::XrpcResp for GetListResponse {
51    const NSID: &'static str = "app.bsky.graph.getList";
52    const ENCODING: &'static str = "application/json";
53    type Output<S: BosStr> = GetListOutput<S>;
54    type Err = jacquard_common::xrpc::GenericError;
55}
56
57impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for GetList<S> {
58    const NSID: &'static str = "app.bsky.graph.getList";
59    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
60    type Response = GetListResponse;
61}
62
63/** Endpoint marker for the `app.bsky.graph.getList` query.
64
65Path: `/xrpc/app.bsky.graph.getList`. The request payload type is `GetList<S>`; send that request with `jacquard::Client` or use this marker through lower-level `XrpcEndpoint` APIs.*/
66pub struct GetListRequest;
67impl jacquard_common::xrpc::XrpcEndpoint for GetListRequest {
68    const PATH: &'static str = "/xrpc/app.bsky.graph.getList";
69    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
70    type Request<S: BosStr> = GetList<S>;
71    type Response = GetListResponse;
72}
73
74fn _default_limit() -> Option<i64> {
75    Some(50i64)
76}
77
78pub mod get_list_state {
79
80    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
81    #[allow(unused)]
82    use ::core::marker::PhantomData;
83    mod sealed {
84        pub trait Sealed {}
85    }
86    /// State trait tracking which required fields have been set
87    pub trait State: sealed::Sealed {
88        type List;
89    }
90    /// Empty state - all required fields are unset
91    pub struct Empty(());
92    impl sealed::Sealed for Empty {}
93    impl State for Empty {
94        type List = Unset;
95    }
96    ///State transition - sets the `list` field to Set
97    pub struct SetList<St: State = Empty>(PhantomData<fn() -> St>);
98    impl<St: State> sealed::Sealed for SetList<St> {}
99    impl<St: State> State for SetList<St> {
100        type List = Set<members::list>;
101    }
102    /// Marker types for field names
103    #[allow(non_camel_case_types)]
104    pub mod members {
105        ///Marker type for the `list` field
106        pub struct list(());
107    }
108}
109
110/// Builder for constructing an instance of this type.
111pub struct GetListBuilder<St: get_list_state::State, S: BosStr = DefaultStr> {
112    _state: PhantomData<fn() -> St>,
113    _fields: (Option<S>, Option<i64>, Option<AtUri<S>>),
114    _type: PhantomData<fn() -> S>,
115}
116
117impl GetList<DefaultStr> {
118    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
119    pub fn new() -> GetListBuilder<get_list_state::Empty, DefaultStr> {
120        GetListBuilder::new()
121    }
122}
123
124impl<S: BosStr> GetList<S> {
125    /// Create a new builder for this type
126    pub fn builder() -> GetListBuilder<get_list_state::Empty, S> {
127        GetListBuilder::builder()
128    }
129}
130
131impl GetListBuilder<get_list_state::Empty, DefaultStr> {
132    /// Create a new builder with all fields unset, using the default string type, if needed
133    pub fn new() -> Self {
134        GetListBuilder {
135            _state: PhantomData,
136            _fields: (None, None, None),
137            _type: PhantomData,
138        }
139    }
140}
141
142impl<S: BosStr> GetListBuilder<get_list_state::Empty, S> {
143    /// Create a new builder with all fields unset
144    pub fn builder() -> Self {
145        GetListBuilder {
146            _state: PhantomData,
147            _fields: (None, None, None),
148            _type: PhantomData,
149        }
150    }
151}
152
153impl<St: get_list_state::State, S: BosStr> GetListBuilder<St, S> {
154    /// Set the `cursor` field (optional)
155    pub fn cursor(mut self, value: impl Into<Option<S>>) -> Self {
156        self._fields.0 = value.into();
157        self
158    }
159    /// Set the `cursor` field to an Option value (optional)
160    pub fn maybe_cursor(mut self, value: Option<S>) -> Self {
161        self._fields.0 = value;
162        self
163    }
164}
165
166impl<St: get_list_state::State, S: BosStr> GetListBuilder<St, S> {
167    /// Set the `limit` field (optional)
168    pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
169        self._fields.1 = value.into();
170        self
171    }
172    /// Set the `limit` field to an Option value (optional)
173    pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
174        self._fields.1 = value;
175        self
176    }
177}
178
179impl<St, S: BosStr> GetListBuilder<St, S>
180where
181    St: get_list_state::State,
182    St::List: get_list_state::IsUnset,
183{
184    /// Set the `list` field (required)
185    pub fn list(
186        mut self,
187        value: impl Into<AtUri<S>>,
188    ) -> GetListBuilder<get_list_state::SetList<St>, S> {
189        self._fields.2 = Option::Some(value.into());
190        GetListBuilder {
191            _state: PhantomData,
192            _fields: self._fields,
193            _type: PhantomData,
194        }
195    }
196}
197
198impl<St, S: BosStr> GetListBuilder<St, S>
199where
200    St: get_list_state::State,
201    St::List: get_list_state::IsSet,
202{
203    /// Build the final struct.
204    pub fn build(self) -> GetList<S> {
205        GetList {
206            cursor: self._fields.0,
207            limit: self._fields.1,
208            list: self._fields.2.unwrap(),
209        }
210    }
211}