atproto blogging
at main 681 lines 25 kB view raw
1// @generated by jacquard-lexicon. DO NOT EDIT. 2// 3// Lexicon: com.atproto.sync.listRepos 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 ListRepos<'a> { 19 #[serde(skip_serializing_if = "std::option::Option::is_none")] 20 #[serde(borrow)] 21 pub cursor: std::option::Option<jacquard_common::CowStr<'a>>, 22 ///(default: 500, min: 1, max: 1000) 23 #[serde(skip_serializing_if = "std::option::Option::is_none")] 24 pub limit: std::option::Option<i64>, 25} 26 27pub mod list_repos_state { 28 29 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 30 #[allow(unused)] 31 use ::core::marker::PhantomData; 32 mod sealed { 33 pub trait Sealed {} 34 } 35 /// State trait tracking which required fields have been set 36 pub trait State: sealed::Sealed {} 37 /// Empty state - all required fields are unset 38 pub struct Empty(()); 39 impl sealed::Sealed for Empty {} 40 impl State for Empty {} 41 /// Marker types for field names 42 #[allow(non_camel_case_types)] 43 pub mod members {} 44} 45 46/// Builder for constructing an instance of this type 47pub struct ListReposBuilder<'a, S: list_repos_state::State> { 48 _phantom_state: ::core::marker::PhantomData<fn() -> S>, 49 __unsafe_private_named: ( 50 ::core::option::Option<jacquard_common::CowStr<'a>>, 51 ::core::option::Option<i64>, 52 ), 53 _phantom: ::core::marker::PhantomData<&'a ()>, 54} 55 56impl<'a> ListRepos<'a> { 57 /// Create a new builder for this type 58 pub fn new() -> ListReposBuilder<'a, list_repos_state::Empty> { 59 ListReposBuilder::new() 60 } 61} 62 63impl<'a> ListReposBuilder<'a, list_repos_state::Empty> { 64 /// Create a new builder with all fields unset 65 pub fn new() -> Self { 66 ListReposBuilder { 67 _phantom_state: ::core::marker::PhantomData, 68 __unsafe_private_named: (None, None), 69 _phantom: ::core::marker::PhantomData, 70 } 71 } 72} 73 74impl<'a, S: list_repos_state::State> ListReposBuilder<'a, S> { 75 /// Set the `cursor` field (optional) 76 pub fn cursor( 77 mut self, 78 value: impl Into<Option<jacquard_common::CowStr<'a>>>, 79 ) -> Self { 80 self.__unsafe_private_named.0 = value.into(); 81 self 82 } 83 /// Set the `cursor` field to an Option value (optional) 84 pub fn maybe_cursor(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self { 85 self.__unsafe_private_named.0 = value; 86 self 87 } 88} 89 90impl<'a, S: list_repos_state::State> ListReposBuilder<'a, S> { 91 /// Set the `limit` field (optional) 92 pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self { 93 self.__unsafe_private_named.1 = value.into(); 94 self 95 } 96 /// Set the `limit` field to an Option value (optional) 97 pub fn maybe_limit(mut self, value: Option<i64>) -> Self { 98 self.__unsafe_private_named.1 = value; 99 self 100 } 101} 102 103impl<'a, S> ListReposBuilder<'a, S> 104where 105 S: list_repos_state::State, 106{ 107 /// Build the final struct 108 pub fn build(self) -> ListRepos<'a> { 109 ListRepos { 110 cursor: self.__unsafe_private_named.0, 111 limit: self.__unsafe_private_named.1, 112 } 113 } 114} 115 116#[jacquard_derive::lexicon] 117#[derive( 118 serde::Serialize, 119 serde::Deserialize, 120 Debug, 121 Clone, 122 PartialEq, 123 Eq, 124 jacquard_derive::IntoStatic 125)] 126#[serde(rename_all = "camelCase")] 127pub struct ListReposOutput<'a> { 128 #[serde(skip_serializing_if = "std::option::Option::is_none")] 129 #[serde(borrow)] 130 pub cursor: std::option::Option<jacquard_common::CowStr<'a>>, 131 #[serde(borrow)] 132 pub repos: Vec<crate::com_atproto::sync::list_repos::Repo<'a>>, 133} 134 135/// Response type for 136///com.atproto.sync.listRepos 137pub struct ListReposResponse; 138impl jacquard_common::xrpc::XrpcResp for ListReposResponse { 139 const NSID: &'static str = "com.atproto.sync.listRepos"; 140 const ENCODING: &'static str = "application/json"; 141 type Output<'de> = ListReposOutput<'de>; 142 type Err<'de> = jacquard_common::xrpc::GenericError<'de>; 143} 144 145impl<'a> jacquard_common::xrpc::XrpcRequest for ListRepos<'a> { 146 const NSID: &'static str = "com.atproto.sync.listRepos"; 147 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query; 148 type Response = ListReposResponse; 149} 150 151/// Endpoint type for 152///com.atproto.sync.listRepos 153pub struct ListReposRequest; 154impl jacquard_common::xrpc::XrpcEndpoint for ListReposRequest { 155 const PATH: &'static str = "/xrpc/com.atproto.sync.listRepos"; 156 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query; 157 type Request<'de> = ListRepos<'de>; 158 type Response = ListReposResponse; 159} 160 161#[jacquard_derive::lexicon] 162#[derive( 163 serde::Serialize, 164 serde::Deserialize, 165 Debug, 166 Clone, 167 PartialEq, 168 Eq, 169 jacquard_derive::IntoStatic 170)] 171#[serde(rename_all = "camelCase")] 172pub struct Repo<'a> { 173 #[serde(skip_serializing_if = "std::option::Option::is_none")] 174 pub active: std::option::Option<bool>, 175 #[serde(borrow)] 176 pub did: jacquard_common::types::string::Did<'a>, 177 /// Current repo commit CID 178 #[serde(borrow)] 179 pub head: jacquard_common::types::string::Cid<'a>, 180 pub rev: jacquard_common::types::string::Tid, 181 /// If active=false, this optional field indicates a possible reason for why the account is not active. If active=false and no status is supplied, then the host makes no claim for why the repository is no longer being hosted. 182 #[serde(skip_serializing_if = "std::option::Option::is_none")] 183 #[serde(borrow)] 184 pub status: std::option::Option<RepoStatus<'a>>, 185} 186 187pub mod repo_state { 188 189 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 190 #[allow(unused)] 191 use ::core::marker::PhantomData; 192 mod sealed { 193 pub trait Sealed {} 194 } 195 /// State trait tracking which required fields have been set 196 pub trait State: sealed::Sealed { 197 type Did; 198 type Rev; 199 type Head; 200 } 201 /// Empty state - all required fields are unset 202 pub struct Empty(()); 203 impl sealed::Sealed for Empty {} 204 impl State for Empty { 205 type Did = Unset; 206 type Rev = Unset; 207 type Head = Unset; 208 } 209 ///State transition - sets the `did` field to Set 210 pub struct SetDid<S: State = Empty>(PhantomData<fn() -> S>); 211 impl<S: State> sealed::Sealed for SetDid<S> {} 212 impl<S: State> State for SetDid<S> { 213 type Did = Set<members::did>; 214 type Rev = S::Rev; 215 type Head = S::Head; 216 } 217 ///State transition - sets the `rev` field to Set 218 pub struct SetRev<S: State = Empty>(PhantomData<fn() -> S>); 219 impl<S: State> sealed::Sealed for SetRev<S> {} 220 impl<S: State> State for SetRev<S> { 221 type Did = S::Did; 222 type Rev = Set<members::rev>; 223 type Head = S::Head; 224 } 225 ///State transition - sets the `head` field to Set 226 pub struct SetHead<S: State = Empty>(PhantomData<fn() -> S>); 227 impl<S: State> sealed::Sealed for SetHead<S> {} 228 impl<S: State> State for SetHead<S> { 229 type Did = S::Did; 230 type Rev = S::Rev; 231 type Head = Set<members::head>; 232 } 233 /// Marker types for field names 234 #[allow(non_camel_case_types)] 235 pub mod members { 236 ///Marker type for the `did` field 237 pub struct did(()); 238 ///Marker type for the `rev` field 239 pub struct rev(()); 240 ///Marker type for the `head` field 241 pub struct head(()); 242 } 243} 244 245/// Builder for constructing an instance of this type 246pub struct RepoBuilder<'a, S: repo_state::State> { 247 _phantom_state: ::core::marker::PhantomData<fn() -> S>, 248 __unsafe_private_named: ( 249 ::core::option::Option<bool>, 250 ::core::option::Option<jacquard_common::types::string::Did<'a>>, 251 ::core::option::Option<jacquard_common::types::string::Cid<'a>>, 252 ::core::option::Option<jacquard_common::types::string::Tid>, 253 ::core::option::Option<RepoStatus<'a>>, 254 ), 255 _phantom: ::core::marker::PhantomData<&'a ()>, 256} 257 258impl<'a> Repo<'a> { 259 /// Create a new builder for this type 260 pub fn new() -> RepoBuilder<'a, repo_state::Empty> { 261 RepoBuilder::new() 262 } 263} 264 265impl<'a> RepoBuilder<'a, repo_state::Empty> { 266 /// Create a new builder with all fields unset 267 pub fn new() -> Self { 268 RepoBuilder { 269 _phantom_state: ::core::marker::PhantomData, 270 __unsafe_private_named: (None, None, None, None, None), 271 _phantom: ::core::marker::PhantomData, 272 } 273 } 274} 275 276impl<'a, S: repo_state::State> RepoBuilder<'a, S> { 277 /// Set the `active` field (optional) 278 pub fn active(mut self, value: impl Into<Option<bool>>) -> Self { 279 self.__unsafe_private_named.0 = value.into(); 280 self 281 } 282 /// Set the `active` field to an Option value (optional) 283 pub fn maybe_active(mut self, value: Option<bool>) -> Self { 284 self.__unsafe_private_named.0 = value; 285 self 286 } 287} 288 289impl<'a, S> RepoBuilder<'a, S> 290where 291 S: repo_state::State, 292 S::Did: repo_state::IsUnset, 293{ 294 /// Set the `did` field (required) 295 pub fn did( 296 mut self, 297 value: impl Into<jacquard_common::types::string::Did<'a>>, 298 ) -> RepoBuilder<'a, repo_state::SetDid<S>> { 299 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); 300 RepoBuilder { 301 _phantom_state: ::core::marker::PhantomData, 302 __unsafe_private_named: self.__unsafe_private_named, 303 _phantom: ::core::marker::PhantomData, 304 } 305 } 306} 307 308impl<'a, S> RepoBuilder<'a, S> 309where 310 S: repo_state::State, 311 S::Head: repo_state::IsUnset, 312{ 313 /// Set the `head` field (required) 314 pub fn head( 315 mut self, 316 value: impl Into<jacquard_common::types::string::Cid<'a>>, 317 ) -> RepoBuilder<'a, repo_state::SetHead<S>> { 318 self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into()); 319 RepoBuilder { 320 _phantom_state: ::core::marker::PhantomData, 321 __unsafe_private_named: self.__unsafe_private_named, 322 _phantom: ::core::marker::PhantomData, 323 } 324 } 325} 326 327impl<'a, S> RepoBuilder<'a, S> 328where 329 S: repo_state::State, 330 S::Rev: repo_state::IsUnset, 331{ 332 /// Set the `rev` field (required) 333 pub fn rev( 334 mut self, 335 value: impl Into<jacquard_common::types::string::Tid>, 336 ) -> RepoBuilder<'a, repo_state::SetRev<S>> { 337 self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into()); 338 RepoBuilder { 339 _phantom_state: ::core::marker::PhantomData, 340 __unsafe_private_named: self.__unsafe_private_named, 341 _phantom: ::core::marker::PhantomData, 342 } 343 } 344} 345 346impl<'a, S: repo_state::State> RepoBuilder<'a, S> { 347 /// Set the `status` field (optional) 348 pub fn status(mut self, value: impl Into<Option<RepoStatus<'a>>>) -> Self { 349 self.__unsafe_private_named.4 = value.into(); 350 self 351 } 352 /// Set the `status` field to an Option value (optional) 353 pub fn maybe_status(mut self, value: Option<RepoStatus<'a>>) -> Self { 354 self.__unsafe_private_named.4 = value; 355 self 356 } 357} 358 359impl<'a, S> RepoBuilder<'a, S> 360where 361 S: repo_state::State, 362 S::Did: repo_state::IsSet, 363 S::Rev: repo_state::IsSet, 364 S::Head: repo_state::IsSet, 365{ 366 /// Build the final struct 367 pub fn build(self) -> Repo<'a> { 368 Repo { 369 active: self.__unsafe_private_named.0, 370 did: self.__unsafe_private_named.1.unwrap(), 371 head: self.__unsafe_private_named.2.unwrap(), 372 rev: self.__unsafe_private_named.3.unwrap(), 373 status: self.__unsafe_private_named.4, 374 extra_data: Default::default(), 375 } 376 } 377 /// Build the final struct with custom extra_data 378 pub fn build_with_data( 379 self, 380 extra_data: std::collections::BTreeMap< 381 jacquard_common::smol_str::SmolStr, 382 jacquard_common::types::value::Data<'a>, 383 >, 384 ) -> Repo<'a> { 385 Repo { 386 active: self.__unsafe_private_named.0, 387 did: self.__unsafe_private_named.1.unwrap(), 388 head: self.__unsafe_private_named.2.unwrap(), 389 rev: self.__unsafe_private_named.3.unwrap(), 390 status: self.__unsafe_private_named.4, 391 extra_data: Some(extra_data), 392 } 393 } 394} 395 396/// If active=false, this optional field indicates a possible reason for why the account is not active. If active=false and no status is supplied, then the host makes no claim for why the repository is no longer being hosted. 397#[derive(Debug, Clone, PartialEq, Eq, Hash)] 398pub enum RepoStatus<'a> { 399 Takendown, 400 Suspended, 401 Deleted, 402 Deactivated, 403 Desynchronized, 404 Throttled, 405 Other(jacquard_common::CowStr<'a>), 406} 407 408impl<'a> RepoStatus<'a> { 409 pub fn as_str(&self) -> &str { 410 match self { 411 Self::Takendown => "takendown", 412 Self::Suspended => "suspended", 413 Self::Deleted => "deleted", 414 Self::Deactivated => "deactivated", 415 Self::Desynchronized => "desynchronized", 416 Self::Throttled => "throttled", 417 Self::Other(s) => s.as_ref(), 418 } 419 } 420} 421 422impl<'a> From<&'a str> for RepoStatus<'a> { 423 fn from(s: &'a str) -> Self { 424 match s { 425 "takendown" => Self::Takendown, 426 "suspended" => Self::Suspended, 427 "deleted" => Self::Deleted, 428 "deactivated" => Self::Deactivated, 429 "desynchronized" => Self::Desynchronized, 430 "throttled" => Self::Throttled, 431 _ => Self::Other(jacquard_common::CowStr::from(s)), 432 } 433 } 434} 435 436impl<'a> From<String> for RepoStatus<'a> { 437 fn from(s: String) -> Self { 438 match s.as_str() { 439 "takendown" => Self::Takendown, 440 "suspended" => Self::Suspended, 441 "deleted" => Self::Deleted, 442 "deactivated" => Self::Deactivated, 443 "desynchronized" => Self::Desynchronized, 444 "throttled" => Self::Throttled, 445 _ => Self::Other(jacquard_common::CowStr::from(s)), 446 } 447 } 448} 449 450impl<'a> core::fmt::Display for RepoStatus<'a> { 451 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 452 write!(f, "{}", self.as_str()) 453 } 454} 455 456impl<'a> AsRef<str> for RepoStatus<'a> { 457 fn as_ref(&self) -> &str { 458 self.as_str() 459 } 460} 461 462impl<'a> serde::Serialize for RepoStatus<'a> { 463 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> 464 where 465 S: serde::Serializer, 466 { 467 serializer.serialize_str(self.as_str()) 468 } 469} 470 471impl<'de, 'a> serde::Deserialize<'de> for RepoStatus<'a> 472where 473 'de: 'a, 474{ 475 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> 476 where 477 D: serde::Deserializer<'de>, 478 { 479 let s = <&'de str>::deserialize(deserializer)?; 480 Ok(Self::from(s)) 481 } 482} 483 484impl<'a> Default for RepoStatus<'a> { 485 fn default() -> Self { 486 Self::Other(Default::default()) 487 } 488} 489 490impl jacquard_common::IntoStatic for RepoStatus<'_> { 491 type Output = RepoStatus<'static>; 492 fn into_static(self) -> Self::Output { 493 match self { 494 RepoStatus::Takendown => RepoStatus::Takendown, 495 RepoStatus::Suspended => RepoStatus::Suspended, 496 RepoStatus::Deleted => RepoStatus::Deleted, 497 RepoStatus::Deactivated => RepoStatus::Deactivated, 498 RepoStatus::Desynchronized => RepoStatus::Desynchronized, 499 RepoStatus::Throttled => RepoStatus::Throttled, 500 RepoStatus::Other(v) => RepoStatus::Other(v.into_static()), 501 } 502 } 503} 504 505fn lexicon_doc_com_atproto_sync_listRepos() -> ::jacquard_lexicon::lexicon::LexiconDoc< 506 'static, 507> { 508 ::jacquard_lexicon::lexicon::LexiconDoc { 509 lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, 510 id: ::jacquard_common::CowStr::new_static("com.atproto.sync.listRepos"), 511 revision: None, 512 description: None, 513 defs: { 514 let mut map = ::alloc::collections::BTreeMap::new(); 515 map.insert( 516 ::jacquard_common::smol_str::SmolStr::new_static("main"), 517 ::jacquard_lexicon::lexicon::LexUserType::XrpcQuery(::jacquard_lexicon::lexicon::LexXrpcQuery { 518 description: None, 519 parameters: Some( 520 ::jacquard_lexicon::lexicon::LexXrpcQueryParameter::Params(::jacquard_lexicon::lexicon::LexXrpcParameters { 521 description: None, 522 required: None, 523 properties: { 524 #[allow(unused_mut)] 525 let mut map = ::alloc::collections::BTreeMap::new(); 526 map.insert( 527 ::jacquard_common::smol_str::SmolStr::new_static("cursor"), 528 ::jacquard_lexicon::lexicon::LexXrpcParametersProperty::String(::jacquard_lexicon::lexicon::LexString { 529 description: None, 530 format: None, 531 default: None, 532 min_length: None, 533 max_length: None, 534 min_graphemes: None, 535 max_graphemes: None, 536 r#enum: None, 537 r#const: None, 538 known_values: None, 539 }), 540 ); 541 map.insert( 542 ::jacquard_common::smol_str::SmolStr::new_static("limit"), 543 ::jacquard_lexicon::lexicon::LexXrpcParametersProperty::Integer(::jacquard_lexicon::lexicon::LexInteger { 544 description: None, 545 default: None, 546 minimum: None, 547 maximum: None, 548 r#enum: None, 549 r#const: None, 550 }), 551 ); 552 map 553 }, 554 }), 555 ), 556 output: None, 557 errors: None, 558 }), 559 ); 560 map.insert( 561 ::jacquard_common::smol_str::SmolStr::new_static("repo"), 562 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 563 description: None, 564 required: Some( 565 vec![ 566 ::jacquard_common::smol_str::SmolStr::new_static("did"), 567 ::jacquard_common::smol_str::SmolStr::new_static("head"), 568 ::jacquard_common::smol_str::SmolStr::new_static("rev") 569 ], 570 ), 571 nullable: None, 572 properties: { 573 #[allow(unused_mut)] 574 let mut map = ::alloc::collections::BTreeMap::new(); 575 map.insert( 576 ::jacquard_common::smol_str::SmolStr::new_static("active"), 577 ::jacquard_lexicon::lexicon::LexObjectProperty::Boolean(::jacquard_lexicon::lexicon::LexBoolean { 578 description: None, 579 default: None, 580 r#const: None, 581 }), 582 ); 583 map.insert( 584 ::jacquard_common::smol_str::SmolStr::new_static("did"), 585 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 586 description: None, 587 format: Some( 588 ::jacquard_lexicon::lexicon::LexStringFormat::Did, 589 ), 590 default: None, 591 min_length: None, 592 max_length: None, 593 min_graphemes: None, 594 max_graphemes: None, 595 r#enum: None, 596 r#const: None, 597 known_values: None, 598 }), 599 ); 600 map.insert( 601 ::jacquard_common::smol_str::SmolStr::new_static("head"), 602 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 603 description: Some( 604 ::jacquard_common::CowStr::new_static( 605 "Current repo commit CID", 606 ), 607 ), 608 format: Some( 609 ::jacquard_lexicon::lexicon::LexStringFormat::Cid, 610 ), 611 default: None, 612 min_length: None, 613 max_length: None, 614 min_graphemes: None, 615 max_graphemes: None, 616 r#enum: None, 617 r#const: None, 618 known_values: None, 619 }), 620 ); 621 map.insert( 622 ::jacquard_common::smol_str::SmolStr::new_static("rev"), 623 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 624 description: None, 625 format: Some( 626 ::jacquard_lexicon::lexicon::LexStringFormat::Tid, 627 ), 628 default: None, 629 min_length: None, 630 max_length: None, 631 min_graphemes: None, 632 max_graphemes: None, 633 r#enum: None, 634 r#const: None, 635 known_values: None, 636 }), 637 ); 638 map.insert( 639 ::jacquard_common::smol_str::SmolStr::new_static("status"), 640 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 641 description: Some( 642 ::jacquard_common::CowStr::new_static( 643 "If active=false, this optional field indicates a possible reason for why the account is not active. If active=false and no status is supplied, then the host makes no claim for why the repository is no longer being hosted.", 644 ), 645 ), 646 format: None, 647 default: None, 648 min_length: None, 649 max_length: None, 650 min_graphemes: None, 651 max_graphemes: None, 652 r#enum: None, 653 r#const: None, 654 known_values: None, 655 }), 656 ); 657 map 658 }, 659 }), 660 ); 661 map 662 }, 663 } 664} 665 666impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Repo<'a> { 667 fn nsid() -> &'static str { 668 "com.atproto.sync.listRepos" 669 } 670 fn def_name() -> &'static str { 671 "repo" 672 } 673 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { 674 lexicon_doc_com_atproto_sync_listRepos() 675 } 676 fn validate( 677 &self, 678 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { 679 Ok(()) 680 } 681}