jacquard_api/com_atproto/label/
query_labels.rs1#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11use crate::com_atproto::label::Label;
12#[allow(unused_imports)]
13use core::marker::PhantomData;
14use jacquard_common::deps::smol_str::SmolStr;
15use jacquard_common::types::string::Did;
16use jacquard_common::types::value::Data;
17use jacquard_common::{BosStr, CowStr, DefaultStr, FromStaticStr};
18use jacquard_derive::IntoStatic;
19use serde::{Deserialize, Serialize};
20
21#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
22#[serde(
23 rename_all = "camelCase",
24 bound(deserialize = "S: Deserialize<'de> + BosStr")
25)]
26pub struct QueryLabels<S: BosStr = DefaultStr> {
27 #[serde(skip_serializing_if = "Option::is_none")]
28 pub cursor: Option<S>,
29 #[serde(default = "_default_limit")]
31 #[serde(skip_serializing_if = "Option::is_none")]
32 pub limit: Option<i64>,
33 #[serde(skip_serializing_if = "Option::is_none")]
34 pub sources: Option<Vec<Did<S>>>,
35 pub uri_patterns: Vec<S>,
36}
37
38#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
39#[serde(
40 rename_all = "camelCase",
41 bound(deserialize = "S: Deserialize<'de> + BosStr")
42)]
43pub struct QueryLabelsOutput<S: BosStr = DefaultStr> {
44 #[serde(skip_serializing_if = "Option::is_none")]
45 pub cursor: Option<S>,
46 pub labels: Vec<Label<S>>,
47 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
48 pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
49}
50
51pub struct QueryLabelsResponse;
55impl jacquard_common::xrpc::XrpcResp for QueryLabelsResponse {
56 const NSID: &'static str = "com.atproto.label.queryLabels";
57 const ENCODING: &'static str = "application/json";
58 type Output<S: BosStr> = QueryLabelsOutput<S>;
59 type Err = jacquard_common::xrpc::GenericError;
60}
61
62impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for QueryLabels<S> {
63 const NSID: &'static str = "com.atproto.label.queryLabels";
64 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
65 type Response = QueryLabelsResponse;
66}
67
68pub struct QueryLabelsRequest;
72impl jacquard_common::xrpc::XrpcEndpoint for QueryLabelsRequest {
73 const PATH: &'static str = "/xrpc/com.atproto.label.queryLabels";
74 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
75 type Request<S: BosStr> = QueryLabels<S>;
76 type Response = QueryLabelsResponse;
77}
78
79fn _default_limit() -> Option<i64> {
80 Some(50i64)
81}
82
83pub mod query_labels_state {
84
85 pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
86 #[allow(unused)]
87 use ::core::marker::PhantomData;
88 mod sealed {
89 pub trait Sealed {}
90 }
91 pub trait State: sealed::Sealed {
93 type UriPatterns;
94 }
95 pub struct Empty(());
97 impl sealed::Sealed for Empty {}
98 impl State for Empty {
99 type UriPatterns = Unset;
100 }
101 pub struct SetUriPatterns<St: State = Empty>(PhantomData<fn() -> St>);
103 impl<St: State> sealed::Sealed for SetUriPatterns<St> {}
104 impl<St: State> State for SetUriPatterns<St> {
105 type UriPatterns = Set<members::uri_patterns>;
106 }
107 #[allow(non_camel_case_types)]
109 pub mod members {
110 pub struct uri_patterns(());
112 }
113}
114
115pub struct QueryLabelsBuilder<St: query_labels_state::State, S: BosStr = DefaultStr> {
117 _state: PhantomData<fn() -> St>,
118 _fields: (Option<S>, Option<i64>, Option<Vec<Did<S>>>, Option<Vec<S>>),
119 _type: PhantomData<fn() -> S>,
120}
121
122impl QueryLabels<DefaultStr> {
123 pub fn new() -> QueryLabelsBuilder<query_labels_state::Empty, DefaultStr> {
125 QueryLabelsBuilder::new()
126 }
127}
128
129impl<S: BosStr> QueryLabels<S> {
130 pub fn builder() -> QueryLabelsBuilder<query_labels_state::Empty, S> {
132 QueryLabelsBuilder::builder()
133 }
134}
135
136impl QueryLabelsBuilder<query_labels_state::Empty, DefaultStr> {
137 pub fn new() -> Self {
139 QueryLabelsBuilder {
140 _state: PhantomData,
141 _fields: (None, None, None, None),
142 _type: PhantomData,
143 }
144 }
145}
146
147impl<S: BosStr> QueryLabelsBuilder<query_labels_state::Empty, S> {
148 pub fn builder() -> Self {
150 QueryLabelsBuilder {
151 _state: PhantomData,
152 _fields: (None, None, None, None),
153 _type: PhantomData,
154 }
155 }
156}
157
158impl<St: query_labels_state::State, S: BosStr> QueryLabelsBuilder<St, S> {
159 pub fn cursor(mut self, value: impl Into<Option<S>>) -> Self {
161 self._fields.0 = value.into();
162 self
163 }
164 pub fn maybe_cursor(mut self, value: Option<S>) -> Self {
166 self._fields.0 = value;
167 self
168 }
169}
170
171impl<St: query_labels_state::State, S: BosStr> QueryLabelsBuilder<St, S> {
172 pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
174 self._fields.1 = value.into();
175 self
176 }
177 pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
179 self._fields.1 = value;
180 self
181 }
182}
183
184impl<St: query_labels_state::State, S: BosStr> QueryLabelsBuilder<St, S> {
185 pub fn sources(mut self, value: impl Into<Option<Vec<Did<S>>>>) -> Self {
187 self._fields.2 = value.into();
188 self
189 }
190 pub fn maybe_sources(mut self, value: Option<Vec<Did<S>>>) -> Self {
192 self._fields.2 = value;
193 self
194 }
195}
196
197impl<St, S: BosStr> QueryLabelsBuilder<St, S>
198where
199 St: query_labels_state::State,
200 St::UriPatterns: query_labels_state::IsUnset,
201{
202 pub fn uri_patterns(
204 mut self,
205 value: impl Into<Vec<S>>,
206 ) -> QueryLabelsBuilder<query_labels_state::SetUriPatterns<St>, S> {
207 self._fields.3 = Option::Some(value.into());
208 QueryLabelsBuilder {
209 _state: PhantomData,
210 _fields: self._fields,
211 _type: PhantomData,
212 }
213 }
214}
215
216impl<St, S: BosStr> QueryLabelsBuilder<St, S>
217where
218 St: query_labels_state::State,
219 St::UriPatterns: query_labels_state::IsSet,
220{
221 pub fn build(self) -> QueryLabels<S> {
223 QueryLabels {
224 cursor: self._fields.0,
225 limit: self._fields.1,
226 sources: self._fields.2,
227 uri_patterns: self._fields.3.unwrap(),
228 }
229 }
230}