1#[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 SearchPosts<'a> {
19 #[serde(skip_serializing_if = "std::option::Option::is_none")]
20 #[serde(borrow)]
21 pub author: std::option::Option<jacquard_common::types::ident::AtIdentifier<'a>>,
22 #[serde(skip_serializing_if = "std::option::Option::is_none")]
23 #[serde(borrow)]
24 pub cursor: std::option::Option<jacquard_common::CowStr<'a>>,
25 #[serde(skip_serializing_if = "std::option::Option::is_none")]
26 #[serde(borrow)]
27 pub domain: std::option::Option<jacquard_common::CowStr<'a>>,
28 #[serde(skip_serializing_if = "std::option::Option::is_none")]
29 pub lang: std::option::Option<jacquard_common::types::string::Language>,
30 #[serde(skip_serializing_if = "std::option::Option::is_none")]
32 pub limit: std::option::Option<i64>,
33 #[serde(skip_serializing_if = "std::option::Option::is_none")]
34 #[serde(borrow)]
35 pub mentions: std::option::Option<jacquard_common::types::ident::AtIdentifier<'a>>,
36 #[serde(borrow)]
37 pub q: jacquard_common::CowStr<'a>,
38 #[serde(skip_serializing_if = "std::option::Option::is_none")]
39 #[serde(borrow)]
40 pub since: std::option::Option<jacquard_common::CowStr<'a>>,
41 #[serde(skip_serializing_if = "std::option::Option::is_none")]
43 #[serde(borrow)]
44 pub sort: std::option::Option<jacquard_common::CowStr<'a>>,
45 #[serde(skip_serializing_if = "std::option::Option::is_none")]
46 #[serde(borrow)]
47 pub tag: std::option::Option<Vec<jacquard_common::CowStr<'a>>>,
48 #[serde(skip_serializing_if = "std::option::Option::is_none")]
49 #[serde(borrow)]
50 pub until: std::option::Option<jacquard_common::CowStr<'a>>,
51 #[serde(skip_serializing_if = "std::option::Option::is_none")]
52 #[serde(borrow)]
53 pub url: std::option::Option<jacquard_common::types::string::Uri<'a>>,
54}
55
56pub mod search_posts_state {
57
58 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
59 #[allow(unused)]
60 use ::core::marker::PhantomData;
61 mod sealed {
62 pub trait Sealed {}
63 }
64 pub trait State: sealed::Sealed {
66 type Q;
67 }
68 pub struct Empty(());
70 impl sealed::Sealed for Empty {}
71 impl State for Empty {
72 type Q = Unset;
73 }
74 pub struct SetQ<S: State = Empty>(PhantomData<fn() -> S>);
76 impl<S: State> sealed::Sealed for SetQ<S> {}
77 impl<S: State> State for SetQ<S> {
78 type Q = Set<members::q>;
79 }
80 #[allow(non_camel_case_types)]
82 pub mod members {
83 pub struct q(());
85 }
86}
87
88pub struct SearchPostsBuilder<'a, S: search_posts_state::State> {
90 _phantom_state: ::core::marker::PhantomData<fn() -> S>,
91 __unsafe_private_named: (
92 ::core::option::Option<jacquard_common::types::ident::AtIdentifier<'a>>,
93 ::core::option::Option<jacquard_common::CowStr<'a>>,
94 ::core::option::Option<jacquard_common::CowStr<'a>>,
95 ::core::option::Option<jacquard_common::types::string::Language>,
96 ::core::option::Option<i64>,
97 ::core::option::Option<jacquard_common::types::ident::AtIdentifier<'a>>,
98 ::core::option::Option<jacquard_common::CowStr<'a>>,
99 ::core::option::Option<jacquard_common::CowStr<'a>>,
100 ::core::option::Option<jacquard_common::CowStr<'a>>,
101 ::core::option::Option<Vec<jacquard_common::CowStr<'a>>>,
102 ::core::option::Option<jacquard_common::CowStr<'a>>,
103 ::core::option::Option<jacquard_common::types::string::Uri<'a>>,
104 ),
105 _phantom: ::core::marker::PhantomData<&'a ()>,
106}
107
108impl<'a> SearchPosts<'a> {
109 pub fn new() -> SearchPostsBuilder<'a, search_posts_state::Empty> {
111 SearchPostsBuilder::new()
112 }
113}
114
115impl<'a> SearchPostsBuilder<'a, search_posts_state::Empty> {
116 pub fn new() -> Self {
118 SearchPostsBuilder {
119 _phantom_state: ::core::marker::PhantomData,
120 __unsafe_private_named: (
121 None,
122 None,
123 None,
124 None,
125 None,
126 None,
127 None,
128 None,
129 None,
130 None,
131 None,
132 None,
133 ),
134 _phantom: ::core::marker::PhantomData,
135 }
136 }
137}
138
139impl<'a, S: search_posts_state::State> SearchPostsBuilder<'a, S> {
140 pub fn author(
142 mut self,
143 value: impl Into<Option<jacquard_common::types::ident::AtIdentifier<'a>>>,
144 ) -> Self {
145 self.__unsafe_private_named.0 = value.into();
146 self
147 }
148 pub fn maybe_author(
150 mut self,
151 value: Option<jacquard_common::types::ident::AtIdentifier<'a>>,
152 ) -> Self {
153 self.__unsafe_private_named.0 = value;
154 self
155 }
156}
157
158impl<'a, S: search_posts_state::State> SearchPostsBuilder<'a, S> {
159 pub fn cursor(
161 mut self,
162 value: impl Into<Option<jacquard_common::CowStr<'a>>>,
163 ) -> Self {
164 self.__unsafe_private_named.1 = value.into();
165 self
166 }
167 pub fn maybe_cursor(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self {
169 self.__unsafe_private_named.1 = value;
170 self
171 }
172}
173
174impl<'a, S: search_posts_state::State> SearchPostsBuilder<'a, S> {
175 pub fn domain(
177 mut self,
178 value: impl Into<Option<jacquard_common::CowStr<'a>>>,
179 ) -> Self {
180 self.__unsafe_private_named.2 = value.into();
181 self
182 }
183 pub fn maybe_domain(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self {
185 self.__unsafe_private_named.2 = value;
186 self
187 }
188}
189
190impl<'a, S: search_posts_state::State> SearchPostsBuilder<'a, S> {
191 pub fn lang(
193 mut self,
194 value: impl Into<Option<jacquard_common::types::string::Language>>,
195 ) -> Self {
196 self.__unsafe_private_named.3 = value.into();
197 self
198 }
199 pub fn maybe_lang(
201 mut self,
202 value: Option<jacquard_common::types::string::Language>,
203 ) -> Self {
204 self.__unsafe_private_named.3 = value;
205 self
206 }
207}
208
209impl<'a, S: search_posts_state::State> SearchPostsBuilder<'a, S> {
210 pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
212 self.__unsafe_private_named.4 = value.into();
213 self
214 }
215 pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
217 self.__unsafe_private_named.4 = value;
218 self
219 }
220}
221
222impl<'a, S: search_posts_state::State> SearchPostsBuilder<'a, S> {
223 pub fn mentions(
225 mut self,
226 value: impl Into<Option<jacquard_common::types::ident::AtIdentifier<'a>>>,
227 ) -> Self {
228 self.__unsafe_private_named.5 = value.into();
229 self
230 }
231 pub fn maybe_mentions(
233 mut self,
234 value: Option<jacquard_common::types::ident::AtIdentifier<'a>>,
235 ) -> Self {
236 self.__unsafe_private_named.5 = value;
237 self
238 }
239}
240
241impl<'a, S> SearchPostsBuilder<'a, S>
242where
243 S: search_posts_state::State,
244 S::Q: search_posts_state::IsUnset,
245{
246 pub fn q(
248 mut self,
249 value: impl Into<jacquard_common::CowStr<'a>>,
250 ) -> SearchPostsBuilder<'a, search_posts_state::SetQ<S>> {
251 self.__unsafe_private_named.6 = ::core::option::Option::Some(value.into());
252 SearchPostsBuilder {
253 _phantom_state: ::core::marker::PhantomData,
254 __unsafe_private_named: self.__unsafe_private_named,
255 _phantom: ::core::marker::PhantomData,
256 }
257 }
258}
259
260impl<'a, S: search_posts_state::State> SearchPostsBuilder<'a, S> {
261 pub fn since(
263 mut self,
264 value: impl Into<Option<jacquard_common::CowStr<'a>>>,
265 ) -> Self {
266 self.__unsafe_private_named.7 = value.into();
267 self
268 }
269 pub fn maybe_since(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self {
271 self.__unsafe_private_named.7 = value;
272 self
273 }
274}
275
276impl<'a, S: search_posts_state::State> SearchPostsBuilder<'a, S> {
277 pub fn sort(
279 mut self,
280 value: impl Into<Option<jacquard_common::CowStr<'a>>>,
281 ) -> Self {
282 self.__unsafe_private_named.8 = value.into();
283 self
284 }
285 pub fn maybe_sort(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self {
287 self.__unsafe_private_named.8 = value;
288 self
289 }
290}
291
292impl<'a, S: search_posts_state::State> SearchPostsBuilder<'a, S> {
293 pub fn tag(
295 mut self,
296 value: impl Into<Option<Vec<jacquard_common::CowStr<'a>>>>,
297 ) -> Self {
298 self.__unsafe_private_named.9 = value.into();
299 self
300 }
301 pub fn maybe_tag(mut self, value: Option<Vec<jacquard_common::CowStr<'a>>>) -> Self {
303 self.__unsafe_private_named.9 = value;
304 self
305 }
306}
307
308impl<'a, S: search_posts_state::State> SearchPostsBuilder<'a, S> {
309 pub fn until(
311 mut self,
312 value: impl Into<Option<jacquard_common::CowStr<'a>>>,
313 ) -> Self {
314 self.__unsafe_private_named.10 = value.into();
315 self
316 }
317 pub fn maybe_until(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self {
319 self.__unsafe_private_named.10 = value;
320 self
321 }
322}
323
324impl<'a, S: search_posts_state::State> SearchPostsBuilder<'a, S> {
325 pub fn url(
327 mut self,
328 value: impl Into<Option<jacquard_common::types::string::Uri<'a>>>,
329 ) -> Self {
330 self.__unsafe_private_named.11 = value.into();
331 self
332 }
333 pub fn maybe_url(
335 mut self,
336 value: Option<jacquard_common::types::string::Uri<'a>>,
337 ) -> Self {
338 self.__unsafe_private_named.11 = value;
339 self
340 }
341}
342
343impl<'a, S> SearchPostsBuilder<'a, S>
344where
345 S: search_posts_state::State,
346 S::Q: search_posts_state::IsSet,
347{
348 pub fn build(self) -> SearchPosts<'a> {
350 SearchPosts {
351 author: self.__unsafe_private_named.0,
352 cursor: self.__unsafe_private_named.1,
353 domain: self.__unsafe_private_named.2,
354 lang: self.__unsafe_private_named.3,
355 limit: self.__unsafe_private_named.4,
356 mentions: self.__unsafe_private_named.5,
357 q: self.__unsafe_private_named.6.unwrap(),
358 since: self.__unsafe_private_named.7,
359 sort: self.__unsafe_private_named.8,
360 tag: self.__unsafe_private_named.9,
361 until: self.__unsafe_private_named.10,
362 url: self.__unsafe_private_named.11,
363 }
364 }
365}
366
367#[jacquard_derive::lexicon]
368#[derive(
369 serde::Serialize,
370 serde::Deserialize,
371 Debug,
372 Clone,
373 PartialEq,
374 Eq,
375 jacquard_derive::IntoStatic
376)]
377#[serde(rename_all = "camelCase")]
378pub struct SearchPostsOutput<'a> {
379 #[serde(skip_serializing_if = "std::option::Option::is_none")]
380 #[serde(borrow)]
381 pub cursor: std::option::Option<jacquard_common::CowStr<'a>>,
382 #[serde(skip_serializing_if = "std::option::Option::is_none")]
384 pub hits_total: std::option::Option<i64>,
385 #[serde(borrow)]
386 pub posts: Vec<crate::app_bsky::feed::PostView<'a>>,
387}
388
389#[jacquard_derive::open_union]
390#[derive(
391 serde::Serialize,
392 serde::Deserialize,
393 Debug,
394 Clone,
395 PartialEq,
396 Eq,
397 thiserror::Error,
398 miette::Diagnostic,
399 jacquard_derive::IntoStatic
400)]
401#[serde(tag = "error", content = "message")]
402#[serde(bound(deserialize = "'de: 'a"))]
403pub enum SearchPostsError<'a> {
404 #[serde(rename = "BadQueryString")]
405 BadQueryString(std::option::Option<String>),
406}
407
408impl std::fmt::Display for SearchPostsError<'_> {
409 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
410 match self {
411 Self::BadQueryString(msg) => {
412 write!(f, "BadQueryString")?;
413 if let Some(msg) = msg {
414 write!(f, ": {}", msg)?;
415 }
416 Ok(())
417 }
418 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
419 }
420 }
421}
422
423pub struct SearchPostsResponse;
426impl jacquard_common::xrpc::XrpcResp for SearchPostsResponse {
427 const NSID: &'static str = "app.bsky.feed.searchPosts";
428 const ENCODING: &'static str = "application/json";
429 type Output<'de> = SearchPostsOutput<'de>;
430 type Err<'de> = SearchPostsError<'de>;
431}
432
433impl<'a> jacquard_common::xrpc::XrpcRequest for SearchPosts<'a> {
434 const NSID: &'static str = "app.bsky.feed.searchPosts";
435 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
436 type Response = SearchPostsResponse;
437}
438
439pub struct SearchPostsRequest;
442impl jacquard_common::xrpc::XrpcEndpoint for SearchPostsRequest {
443 const PATH: &'static str = "/xrpc/app.bsky.feed.searchPosts";
444 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
445 type Request<'de> = SearchPosts<'de>;
446 type Response = SearchPostsResponse;
447}