atproto blogging
at main 447 lines 15 kB view raw
1// @generated by jacquard-lexicon. DO NOT EDIT. 2// 3// Lexicon: app.bsky.feed.searchPosts 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 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 ///(default: 25, min: 1, max: 100) 31 #[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 ///(default: "latest") 42 #[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 /// State trait tracking which required fields have been set 65 pub trait State: sealed::Sealed { 66 type Q; 67 } 68 /// Empty state - all required fields are unset 69 pub struct Empty(()); 70 impl sealed::Sealed for Empty {} 71 impl State for Empty { 72 type Q = Unset; 73 } 74 ///State transition - sets the `q` field to Set 75 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 /// Marker types for field names 81 #[allow(non_camel_case_types)] 82 pub mod members { 83 ///Marker type for the `q` field 84 pub struct q(()); 85 } 86} 87 88/// Builder for constructing an instance of this type 89pub 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 /// Create a new builder for this type 110 pub fn new() -> SearchPostsBuilder<'a, search_posts_state::Empty> { 111 SearchPostsBuilder::new() 112 } 113} 114 115impl<'a> SearchPostsBuilder<'a, search_posts_state::Empty> { 116 /// Create a new builder with all fields unset 117 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 /// Set the `author` field (optional) 141 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 /// Set the `author` field to an Option value (optional) 149 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 /// Set the `cursor` field (optional) 160 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 /// Set the `cursor` field to an Option value (optional) 168 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 /// Set the `domain` field (optional) 176 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 /// Set the `domain` field to an Option value (optional) 184 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 /// Set the `lang` field (optional) 192 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 /// Set the `lang` field to an Option value (optional) 200 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 /// Set the `limit` field (optional) 211 pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self { 212 self.__unsafe_private_named.4 = value.into(); 213 self 214 } 215 /// Set the `limit` field to an Option value (optional) 216 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 /// Set the `mentions` field (optional) 224 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 /// Set the `mentions` field to an Option value (optional) 232 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 /// Set the `q` field (required) 247 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 /// Set the `since` field (optional) 262 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 /// Set the `since` field to an Option value (optional) 270 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 /// Set the `sort` field (optional) 278 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 /// Set the `sort` field to an Option value (optional) 286 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 /// Set the `tag` field (optional) 294 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 /// Set the `tag` field to an Option value (optional) 302 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 /// Set the `until` field (optional) 310 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 /// Set the `until` field to an Option value (optional) 318 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 /// Set the `url` field (optional) 326 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 /// Set the `url` field to an Option value (optional) 334 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 /// Build the final struct 349 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 /// Count of search hits. Optional, may be rounded/truncated, and may not be possible to paginate through all hits. 383 #[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<jacquard_common::CowStr<'a>>), 406} 407 408impl core::fmt::Display for SearchPostsError<'_> { 409 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::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 423/// Response type for 424///app.bsky.feed.searchPosts 425pub 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 439/// Endpoint type for 440///app.bsky.feed.searchPosts 441pub 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}