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, BosStr, DefaultStr, FromStaticStr};
14use jacquard_common::deps::smol_str::SmolStr;
15use jacquard_common::types::string::Did;
16use jacquard_common::types::value::Data;
17use jacquard_derive::IntoStatic;
18use serde::{Serialize, Deserialize};
19use crate::com_atproto::label::Label;
20
21#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
22#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
23pub struct QueryLabels<S: BosStr = DefaultStr> {
24    #[serde(skip_serializing_if = "Option::is_none")]
25    pub cursor: Option<S>,
26    /// Defaults to `50`. Min: 1. Max: 250.
27    #[serde(default = "_default_limit")]
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub limit: Option<i64>,
30    #[serde(skip_serializing_if = "Option::is_none")]
31    pub sources: Option<Vec<Did<S>>>,
32    pub uri_patterns: Vec<S>,
33}
34
35
36#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
37#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
38pub struct QueryLabelsOutput<S: BosStr = DefaultStr> {
39    #[serde(skip_serializing_if = "Option::is_none")]
40    pub cursor: Option<S>,
41    pub labels: Vec<Label<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 `com.atproto.label.queryLabels` query.
47
48Implements `jacquard_common::xrpc::XrpcResp`; successful bodies decode as `Self::Output<S>`, which is `QueryLabelsOutput<S>` for this endpoint.*/
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<S: BosStr> = QueryLabelsOutput<S>;
54    type Err = jacquard_common::xrpc::GenericError;
55}
56
57impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for QueryLabels<S> {
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 marker for the `com.atproto.label.queryLabels` query.
64
65Path: `/xrpc/com.atproto.label.queryLabels`. The request payload type is `QueryLabels<S>`; send that request with `jacquard::Client` or use this marker through lower-level `XrpcEndpoint` APIs.*/
66pub struct QueryLabelsRequest;
67impl jacquard_common::xrpc::XrpcEndpoint for QueryLabelsRequest {
68    const PATH: &'static str = "/xrpc/com.atproto.label.queryLabels";
69    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
70    type Request<S: BosStr> = QueryLabels<S>;
71    type Response = QueryLabelsResponse;
72}
73
74fn _default_limit() -> Option<i64> {
75    Some(50i64)
76}
77
78pub mod query_labels_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 UriPatterns;
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 UriPatterns = Unset;
95    }
96    ///State transition - sets the `uri_patterns` field to Set
97    pub struct SetUriPatterns<St: State = Empty>(PhantomData<fn() -> St>);
98    impl<St: State> sealed::Sealed for SetUriPatterns<St> {}
99    impl<St: State> State for SetUriPatterns<St> {
100        type UriPatterns = Set<members::uri_patterns>;
101    }
102    /// Marker types for field names
103    #[allow(non_camel_case_types)]
104    pub mod members {
105        ///Marker type for the `uri_patterns` field
106        pub struct uri_patterns(());
107    }
108}
109
110/// Builder for constructing an instance of this type.
111pub struct QueryLabelsBuilder<St: query_labels_state::State, S: BosStr = DefaultStr> {
112    _state: PhantomData<fn() -> St>,
113    _fields: (Option<S>, Option<i64>, Option<Vec<Did<S>>>, Option<Vec<S>>),
114    _type: PhantomData<fn() -> S>,
115}
116
117impl QueryLabels<DefaultStr> {
118    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
119    pub fn new() -> QueryLabelsBuilder<query_labels_state::Empty, DefaultStr> {
120        QueryLabelsBuilder::new()
121    }
122}
123
124impl<S: BosStr> QueryLabels<S> {
125    /// Create a new builder for this type
126    pub fn builder() -> QueryLabelsBuilder<query_labels_state::Empty, S> {
127        QueryLabelsBuilder::builder()
128    }
129}
130
131impl QueryLabelsBuilder<query_labels_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        QueryLabelsBuilder {
135            _state: PhantomData,
136            _fields: (None, None, None, None),
137            _type: PhantomData,
138        }
139    }
140}
141
142impl<S: BosStr> QueryLabelsBuilder<query_labels_state::Empty, S> {
143    /// Create a new builder with all fields unset
144    pub fn builder() -> Self {
145        QueryLabelsBuilder {
146            _state: PhantomData,
147            _fields: (None, None, None, None),
148            _type: PhantomData,
149        }
150    }
151}
152
153impl<St: query_labels_state::State, S: BosStr> QueryLabelsBuilder<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: query_labels_state::State, S: BosStr> QueryLabelsBuilder<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: query_labels_state::State, S: BosStr> QueryLabelsBuilder<St, S> {
180    /// Set the `sources` field (optional)
181    pub fn sources(mut self, value: impl Into<Option<Vec<Did<S>>>>) -> Self {
182        self._fields.2 = value.into();
183        self
184    }
185    /// Set the `sources` field to an Option value (optional)
186    pub fn maybe_sources(mut self, value: Option<Vec<Did<S>>>) -> Self {
187        self._fields.2 = value;
188        self
189    }
190}
191
192impl<St, S: BosStr> QueryLabelsBuilder<St, S>
193where
194    St: query_labels_state::State,
195    St::UriPatterns: query_labels_state::IsUnset,
196{
197    /// Set the `uriPatterns` field (required)
198    pub fn uri_patterns(
199        mut self,
200        value: impl Into<Vec<S>>,
201    ) -> QueryLabelsBuilder<query_labels_state::SetUriPatterns<St>, S> {
202        self._fields.3 = Option::Some(value.into());
203        QueryLabelsBuilder {
204            _state: PhantomData,
205            _fields: self._fields,
206            _type: PhantomData,
207        }
208    }
209}
210
211impl<St, S: BosStr> QueryLabelsBuilder<St, S>
212where
213    St: query_labels_state::State,
214    St::UriPatterns: query_labels_state::IsSet,
215{
216    /// Build the final struct.
217    pub fn build(self) -> QueryLabels<S> {
218        QueryLabels {
219            cursor: self._fields.0,
220            limit: self._fields.1,
221            sources: self._fields.2,
222            uri_patterns: self._fields.3.unwrap(),
223        }
224    }
225}