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