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, 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 #[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
46pub 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
63pub 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 pub trait State: sealed::Sealed {
88 type UriPatterns;
89 }
90 pub struct Empty(());
92 impl sealed::Sealed for Empty {}
93 impl State for Empty {
94 type UriPatterns = Unset;
95 }
96 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 #[allow(non_camel_case_types)]
104 pub mod members {
105 pub struct uri_patterns(());
107 }
108}
109
110pub 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 pub fn new() -> QueryLabelsBuilder<query_labels_state::Empty, DefaultStr> {
120 QueryLabelsBuilder::new()
121 }
122}
123
124impl<S: BosStr> QueryLabels<S> {
125 pub fn builder() -> QueryLabelsBuilder<query_labels_state::Empty, S> {
127 QueryLabelsBuilder::builder()
128 }
129}
130
131impl QueryLabelsBuilder<query_labels_state::Empty, DefaultStr> {
132 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 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 pub fn cursor(mut self, value: impl Into<Option<S>>) -> Self {
156 self._fields.0 = value.into();
157 self
158 }
159 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 pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
169 self._fields.1 = value.into();
170 self
171 }
172 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 pub fn sources(mut self, value: impl Into<Option<Vec<Did<S>>>>) -> Self {
182 self._fields.2 = value.into();
183 self
184 }
185 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 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 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}