Skip to main content

jacquard_api/com_atproto/label/
query_labels.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: com.atproto.label.queryLabels
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::Did;
15use jacquard_derive::{IntoStatic, lexicon};
16use serde::{Serialize, Deserialize};
17use crate::com_atproto::label::Label;
18
19#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
20#[serde(rename_all = "camelCase")]
21pub struct QueryLabels<'a> {
22    #[serde(skip_serializing_if = "Option::is_none")]
23    #[serde(borrow)]
24    pub cursor: Option<CowStr<'a>>,
25    ///Defaults to `50`. Min: 1. Max: 250.
26    #[serde(default = "_default_limit")]
27    #[serde(skip_serializing_if = "Option::is_none")]
28    pub limit: Option<i64>,
29    #[serde(skip_serializing_if = "Option::is_none")]
30    #[serde(borrow)]
31    pub sources: Option<Vec<Did<'a>>>,
32    #[serde(borrow)]
33    pub uri_patterns: Vec<CowStr<'a>>,
34}
35
36
37#[lexicon]
38#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
39#[serde(rename_all = "camelCase")]
40pub struct QueryLabelsOutput<'a> {
41    #[serde(skip_serializing_if = "Option::is_none")]
42    #[serde(borrow)]
43    pub cursor: Option<CowStr<'a>>,
44    #[serde(borrow)]
45    pub labels: Vec<Label<'a>>,
46}
47
48/// Response type for com.atproto.label.queryLabels
49pub struct QueryLabelsResponse;
50impl jacquard_common::xrpc::XrpcResp for QueryLabelsResponse {
51    const NSID: &'static str = "com.atproto.label.queryLabels";
52    const ENCODING: &'static str = "application/json";
53    type Output<'de> = QueryLabelsOutput<'de>;
54    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
55}
56
57impl<'a> jacquard_common::xrpc::XrpcRequest for QueryLabels<'a> {
58    const NSID: &'static str = "com.atproto.label.queryLabels";
59    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
60    type Response = QueryLabelsResponse;
61}
62
63/// Endpoint type for com.atproto.label.queryLabels
64pub struct QueryLabelsRequest;
65impl jacquard_common::xrpc::XrpcEndpoint for QueryLabelsRequest {
66    const PATH: &'static str = "/xrpc/com.atproto.label.queryLabels";
67    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
68    type Request<'de> = QueryLabels<'de>;
69    type Response = QueryLabelsResponse;
70}
71
72fn _default_limit() -> Option<i64> {
73    Some(50i64)
74}
75
76pub mod query_labels_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 UriPatterns;
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 UriPatterns = Unset;
93    }
94    ///State transition - sets the `uri_patterns` field to Set
95    pub struct SetUriPatterns<S: State = Empty>(PhantomData<fn() -> S>);
96    impl<S: State> sealed::Sealed for SetUriPatterns<S> {}
97    impl<S: State> State for SetUriPatterns<S> {
98        type UriPatterns = Set<members::uri_patterns>;
99    }
100    /// Marker types for field names
101    #[allow(non_camel_case_types)]
102    pub mod members {
103        ///Marker type for the `uri_patterns` field
104        pub struct uri_patterns(());
105    }
106}
107
108/// Builder for constructing an instance of this type
109pub struct QueryLabelsBuilder<'a, S: query_labels_state::State> {
110    _state: PhantomData<fn() -> S>,
111    _fields: (
112        Option<CowStr<'a>>,
113        Option<i64>,
114        Option<Vec<Did<'a>>>,
115        Option<Vec<CowStr<'a>>>,
116    ),
117    _lifetime: PhantomData<&'a ()>,
118}
119
120impl<'a> QueryLabels<'a> {
121    /// Create a new builder for this type
122    pub fn new() -> QueryLabelsBuilder<'a, query_labels_state::Empty> {
123        QueryLabelsBuilder::new()
124    }
125}
126
127impl<'a> QueryLabelsBuilder<'a, query_labels_state::Empty> {
128    /// Create a new builder with all fields unset
129    pub fn new() -> Self {
130        QueryLabelsBuilder {
131            _state: PhantomData,
132            _fields: (None, None, None, None),
133            _lifetime: PhantomData,
134        }
135    }
136}
137
138impl<'a, S: query_labels_state::State> QueryLabelsBuilder<'a, S> {
139    /// Set the `cursor` field (optional)
140    pub fn cursor(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
141        self._fields.0 = value.into();
142        self
143    }
144    /// Set the `cursor` field to an Option value (optional)
145    pub fn maybe_cursor(mut self, value: Option<CowStr<'a>>) -> Self {
146        self._fields.0 = value;
147        self
148    }
149}
150
151impl<'a, S: query_labels_state::State> QueryLabelsBuilder<'a, S> {
152    /// Set the `limit` field (optional)
153    pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
154        self._fields.1 = value.into();
155        self
156    }
157    /// Set the `limit` field to an Option value (optional)
158    pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
159        self._fields.1 = value;
160        self
161    }
162}
163
164impl<'a, S: query_labels_state::State> QueryLabelsBuilder<'a, S> {
165    /// Set the `sources` field (optional)
166    pub fn sources(mut self, value: impl Into<Option<Vec<Did<'a>>>>) -> Self {
167        self._fields.2 = value.into();
168        self
169    }
170    /// Set the `sources` field to an Option value (optional)
171    pub fn maybe_sources(mut self, value: Option<Vec<Did<'a>>>) -> Self {
172        self._fields.2 = value;
173        self
174    }
175}
176
177impl<'a, S> QueryLabelsBuilder<'a, S>
178where
179    S: query_labels_state::State,
180    S::UriPatterns: query_labels_state::IsUnset,
181{
182    /// Set the `uriPatterns` field (required)
183    pub fn uri_patterns(
184        mut self,
185        value: impl Into<Vec<CowStr<'a>>>,
186    ) -> QueryLabelsBuilder<'a, query_labels_state::SetUriPatterns<S>> {
187        self._fields.3 = Option::Some(value.into());
188        QueryLabelsBuilder {
189            _state: PhantomData,
190            _fields: self._fields,
191            _lifetime: PhantomData,
192        }
193    }
194}
195
196impl<'a, S> QueryLabelsBuilder<'a, S>
197where
198    S: query_labels_state::State,
199    S::UriPatterns: query_labels_state::IsSet,
200{
201    /// Build the final struct
202    pub fn build(self) -> QueryLabels<'a> {
203        QueryLabels {
204            cursor: self._fields.0,
205            limit: self._fields.1,
206            sources: self._fields.2,
207            uri_patterns: self._fields.3.unwrap(),
208        }
209    }
210}