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;
14use jacquard_common::types::string::AtUri;
15use jacquard_derive::{IntoStatic, lexicon};
16use serde::{Serialize, Deserialize};
17use crate::app_bsky::graph::ListItemView;
18use crate::app_bsky::graph::ListView;
19
20#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
21#[serde(rename_all = "camelCase")]
22pub struct GetList<'a> {
23    #[serde(skip_serializing_if = "Option::is_none")]
24    #[serde(borrow)]
25    pub cursor: Option<CowStr<'a>>,
26    ///Defaults to `50`. Min: 1. Max: 100.
27    #[serde(default = "_default_limit")]
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub limit: Option<i64>,
30    #[serde(borrow)]
31    pub list: AtUri<'a>,
32}
33
34
35#[lexicon]
36#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
37#[serde(rename_all = "camelCase")]
38pub struct GetListOutput<'a> {
39    #[serde(skip_serializing_if = "Option::is_none")]
40    #[serde(borrow)]
41    pub cursor: Option<CowStr<'a>>,
42    #[serde(borrow)]
43    pub items: Vec<ListItemView<'a>>,
44    #[serde(borrow)]
45    pub list: ListView<'a>,
46}
47
48/// Response type for app.bsky.graph.getList
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<'de> = GetListOutput<'de>;
54    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
55}
56
57impl<'a> jacquard_common::xrpc::XrpcRequest for GetList<'a> {
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 type for app.bsky.graph.getList
64pub struct GetListRequest;
65impl jacquard_common::xrpc::XrpcEndpoint for GetListRequest {
66    const PATH: &'static str = "/xrpc/app.bsky.graph.getList";
67    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
68    type Request<'de> = GetList<'de>;
69    type Response = GetListResponse;
70}
71
72fn _default_limit() -> Option<i64> {
73    Some(50i64)
74}
75
76pub mod get_list_state {
77
78    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
79    #[allow(unused)]
80    use ::core::marker::PhantomData;
81    mod sealed {
82        pub trait Sealed {}
83    }
84    /// State trait tracking which required fields have been set
85    pub trait State: sealed::Sealed {
86        type List;
87    }
88    /// Empty state - all required fields are unset
89    pub struct Empty(());
90    impl sealed::Sealed for Empty {}
91    impl State for Empty {
92        type List = Unset;
93    }
94    ///State transition - sets the `list` field to Set
95    pub struct SetList<S: State = Empty>(PhantomData<fn() -> S>);
96    impl<S: State> sealed::Sealed for SetList<S> {}
97    impl<S: State> State for SetList<S> {
98        type List = Set<members::list>;
99    }
100    /// Marker types for field names
101    #[allow(non_camel_case_types)]
102    pub mod members {
103        ///Marker type for the `list` field
104        pub struct list(());
105    }
106}
107
108/// Builder for constructing an instance of this type
109pub struct GetListBuilder<'a, S: get_list_state::State> {
110    _state: PhantomData<fn() -> S>,
111    _fields: (Option<CowStr<'a>>, Option<i64>, Option<AtUri<'a>>),
112    _lifetime: PhantomData<&'a ()>,
113}
114
115impl<'a> GetList<'a> {
116    /// Create a new builder for this type
117    pub fn new() -> GetListBuilder<'a, get_list_state::Empty> {
118        GetListBuilder::new()
119    }
120}
121
122impl<'a> GetListBuilder<'a, get_list_state::Empty> {
123    /// Create a new builder with all fields unset
124    pub fn new() -> Self {
125        GetListBuilder {
126            _state: PhantomData,
127            _fields: (None, None, None),
128            _lifetime: PhantomData,
129        }
130    }
131}
132
133impl<'a, S: get_list_state::State> GetListBuilder<'a, S> {
134    /// Set the `cursor` field (optional)
135    pub fn cursor(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
136        self._fields.0 = value.into();
137        self
138    }
139    /// Set the `cursor` field to an Option value (optional)
140    pub fn maybe_cursor(mut self, value: Option<CowStr<'a>>) -> Self {
141        self._fields.0 = value;
142        self
143    }
144}
145
146impl<'a, S: get_list_state::State> GetListBuilder<'a, S> {
147    /// Set the `limit` field (optional)
148    pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
149        self._fields.1 = value.into();
150        self
151    }
152    /// Set the `limit` field to an Option value (optional)
153    pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
154        self._fields.1 = value;
155        self
156    }
157}
158
159impl<'a, S> GetListBuilder<'a, S>
160where
161    S: get_list_state::State,
162    S::List: get_list_state::IsUnset,
163{
164    /// Set the `list` field (required)
165    pub fn list(
166        mut self,
167        value: impl Into<AtUri<'a>>,
168    ) -> GetListBuilder<'a, get_list_state::SetList<S>> {
169        self._fields.2 = Option::Some(value.into());
170        GetListBuilder {
171            _state: PhantomData,
172            _fields: self._fields,
173            _lifetime: PhantomData,
174        }
175    }
176}
177
178impl<'a, S> GetListBuilder<'a, S>
179where
180    S: get_list_state::State,
181    S::List: get_list_state::IsSet,
182{
183    /// Build the final struct
184    pub fn build(self) -> GetList<'a> {
185        GetList {
186            cursor: self._fields.0,
187            limit: self._fields.1,
188            list: self._fields.2.unwrap(),
189        }
190    }
191}