jacquard_api/com_atproto/label/
query_labels.rs1#[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 #[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
48pub 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
63pub 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 pub trait State: sealed::Sealed {
86 type UriPatterns;
87 }
88 pub struct Empty(());
90 impl sealed::Sealed for Empty {}
91 impl State for Empty {
92 type UriPatterns = Unset;
93 }
94 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 #[allow(non_camel_case_types)]
102 pub mod members {
103 pub struct uri_patterns(());
105 }
106}
107
108pub 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 pub fn new() -> QueryLabelsBuilder<'a, query_labels_state::Empty> {
123 QueryLabelsBuilder::new()
124 }
125}
126
127impl<'a> QueryLabelsBuilder<'a, query_labels_state::Empty> {
128 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 pub fn cursor(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
141 self._fields.0 = value.into();
142 self
143 }
144 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 pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
154 self._fields.1 = value.into();
155 self
156 }
157 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 pub fn sources(mut self, value: impl Into<Option<Vec<Did<'a>>>>) -> Self {
167 self._fields.2 = value.into();
168 self
169 }
170 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 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 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}