atproto blogging
at main 1124 lines 44 kB view raw
1// @generated by jacquard-lexicon. DO NOT EDIT. 2// 3// Lexicon: com.deckbelcher.deck.list 4// 5// This file was automatically generated from Lexicon schemas. 6// Any manual changes will be overwritten on the next regeneration. 7 8/// A card entry in a decklist. 9#[jacquard_derive::lexicon] 10#[derive( 11 serde::Serialize, 12 serde::Deserialize, 13 Debug, 14 Clone, 15 PartialEq, 16 Eq, 17 jacquard_derive::IntoStatic 18)] 19#[serde(rename_all = "camelCase")] 20pub struct Card<'a> { 21 /// Number of copies in the deck. 22 pub quantity: i64, 23 /// Scryfall UUID for the specific printing. 24 #[serde(borrow)] 25 pub scryfall_id: jacquard_common::CowStr<'a>, 26 /// Which section of the deck this card belongs to. Extensible to support format-specific sections. 27 #[serde(borrow)] 28 pub section: CardSection<'a>, 29 /// User annotations for this card in this deck (e.g., "removal", "wincon", "ramp"). 30 #[serde(skip_serializing_if = "std::option::Option::is_none")] 31 #[serde(borrow)] 32 pub tags: std::option::Option<Vec<jacquard_common::CowStr<'a>>>, 33} 34 35pub mod card_state { 36 37 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 38 #[allow(unused)] 39 use ::core::marker::PhantomData; 40 mod sealed { 41 pub trait Sealed {} 42 } 43 /// State trait tracking which required fields have been set 44 pub trait State: sealed::Sealed { 45 type Quantity; 46 type ScryfallId; 47 type Section; 48 } 49 /// Empty state - all required fields are unset 50 pub struct Empty(()); 51 impl sealed::Sealed for Empty {} 52 impl State for Empty { 53 type Quantity = Unset; 54 type ScryfallId = Unset; 55 type Section = Unset; 56 } 57 ///State transition - sets the `quantity` field to Set 58 pub struct SetQuantity<S: State = Empty>(PhantomData<fn() -> S>); 59 impl<S: State> sealed::Sealed for SetQuantity<S> {} 60 impl<S: State> State for SetQuantity<S> { 61 type Quantity = Set<members::quantity>; 62 type ScryfallId = S::ScryfallId; 63 type Section = S::Section; 64 } 65 ///State transition - sets the `scryfall_id` field to Set 66 pub struct SetScryfallId<S: State = Empty>(PhantomData<fn() -> S>); 67 impl<S: State> sealed::Sealed for SetScryfallId<S> {} 68 impl<S: State> State for SetScryfallId<S> { 69 type Quantity = S::Quantity; 70 type ScryfallId = Set<members::scryfall_id>; 71 type Section = S::Section; 72 } 73 ///State transition - sets the `section` field to Set 74 pub struct SetSection<S: State = Empty>(PhantomData<fn() -> S>); 75 impl<S: State> sealed::Sealed for SetSection<S> {} 76 impl<S: State> State for SetSection<S> { 77 type Quantity = S::Quantity; 78 type ScryfallId = S::ScryfallId; 79 type Section = Set<members::section>; 80 } 81 /// Marker types for field names 82 #[allow(non_camel_case_types)] 83 pub mod members { 84 ///Marker type for the `quantity` field 85 pub struct quantity(()); 86 ///Marker type for the `scryfall_id` field 87 pub struct scryfall_id(()); 88 ///Marker type for the `section` field 89 pub struct section(()); 90 } 91} 92 93/// Builder for constructing an instance of this type 94pub struct CardBuilder<'a, S: card_state::State> { 95 _phantom_state: ::core::marker::PhantomData<fn() -> S>, 96 __unsafe_private_named: ( 97 ::core::option::Option<i64>, 98 ::core::option::Option<jacquard_common::CowStr<'a>>, 99 ::core::option::Option<CardSection<'a>>, 100 ::core::option::Option<Vec<jacquard_common::CowStr<'a>>>, 101 ), 102 _phantom: ::core::marker::PhantomData<&'a ()>, 103} 104 105impl<'a> Card<'a> { 106 /// Create a new builder for this type 107 pub fn new() -> CardBuilder<'a, card_state::Empty> { 108 CardBuilder::new() 109 } 110} 111 112impl<'a> CardBuilder<'a, card_state::Empty> { 113 /// Create a new builder with all fields unset 114 pub fn new() -> Self { 115 CardBuilder { 116 _phantom_state: ::core::marker::PhantomData, 117 __unsafe_private_named: (None, None, None, None), 118 _phantom: ::core::marker::PhantomData, 119 } 120 } 121} 122 123impl<'a, S> CardBuilder<'a, S> 124where 125 S: card_state::State, 126 S::Quantity: card_state::IsUnset, 127{ 128 /// Set the `quantity` field (required) 129 pub fn quantity( 130 mut self, 131 value: impl Into<i64>, 132 ) -> CardBuilder<'a, card_state::SetQuantity<S>> { 133 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); 134 CardBuilder { 135 _phantom_state: ::core::marker::PhantomData, 136 __unsafe_private_named: self.__unsafe_private_named, 137 _phantom: ::core::marker::PhantomData, 138 } 139 } 140} 141 142impl<'a, S> CardBuilder<'a, S> 143where 144 S: card_state::State, 145 S::ScryfallId: card_state::IsUnset, 146{ 147 /// Set the `scryfallId` field (required) 148 pub fn scryfall_id( 149 mut self, 150 value: impl Into<jacquard_common::CowStr<'a>>, 151 ) -> CardBuilder<'a, card_state::SetScryfallId<S>> { 152 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); 153 CardBuilder { 154 _phantom_state: ::core::marker::PhantomData, 155 __unsafe_private_named: self.__unsafe_private_named, 156 _phantom: ::core::marker::PhantomData, 157 } 158 } 159} 160 161impl<'a, S> CardBuilder<'a, S> 162where 163 S: card_state::State, 164 S::Section: card_state::IsUnset, 165{ 166 /// Set the `section` field (required) 167 pub fn section( 168 mut self, 169 value: impl Into<CardSection<'a>>, 170 ) -> CardBuilder<'a, card_state::SetSection<S>> { 171 self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into()); 172 CardBuilder { 173 _phantom_state: ::core::marker::PhantomData, 174 __unsafe_private_named: self.__unsafe_private_named, 175 _phantom: ::core::marker::PhantomData, 176 } 177 } 178} 179 180impl<'a, S: card_state::State> CardBuilder<'a, S> { 181 /// Set the `tags` field (optional) 182 pub fn tags( 183 mut self, 184 value: impl Into<Option<Vec<jacquard_common::CowStr<'a>>>>, 185 ) -> Self { 186 self.__unsafe_private_named.3 = value.into(); 187 self 188 } 189 /// Set the `tags` field to an Option value (optional) 190 pub fn maybe_tags( 191 mut self, 192 value: Option<Vec<jacquard_common::CowStr<'a>>>, 193 ) -> Self { 194 self.__unsafe_private_named.3 = value; 195 self 196 } 197} 198 199impl<'a, S> CardBuilder<'a, S> 200where 201 S: card_state::State, 202 S::Quantity: card_state::IsSet, 203 S::ScryfallId: card_state::IsSet, 204 S::Section: card_state::IsSet, 205{ 206 /// Build the final struct 207 pub fn build(self) -> Card<'a> { 208 Card { 209 quantity: self.__unsafe_private_named.0.unwrap(), 210 scryfall_id: self.__unsafe_private_named.1.unwrap(), 211 section: self.__unsafe_private_named.2.unwrap(), 212 tags: self.__unsafe_private_named.3, 213 extra_data: Default::default(), 214 } 215 } 216 /// Build the final struct with custom extra_data 217 pub fn build_with_data( 218 self, 219 extra_data: std::collections::BTreeMap< 220 jacquard_common::smol_str::SmolStr, 221 jacquard_common::types::value::Data<'a>, 222 >, 223 ) -> Card<'a> { 224 Card { 225 quantity: self.__unsafe_private_named.0.unwrap(), 226 scryfall_id: self.__unsafe_private_named.1.unwrap(), 227 section: self.__unsafe_private_named.2.unwrap(), 228 tags: self.__unsafe_private_named.3, 229 extra_data: Some(extra_data), 230 } 231 } 232} 233 234/// Which section of the deck this card belongs to. Extensible to support format-specific sections. 235#[derive(Debug, Clone, PartialEq, Eq, Hash)] 236pub enum CardSection<'a> { 237 Mainboard, 238 Sideboard, 239 Maybeboard, 240 Commander, 241 Other(jacquard_common::CowStr<'a>), 242} 243 244impl<'a> CardSection<'a> { 245 pub fn as_str(&self) -> &str { 246 match self { 247 Self::Mainboard => "mainboard", 248 Self::Sideboard => "sideboard", 249 Self::Maybeboard => "maybeboard", 250 Self::Commander => "commander", 251 Self::Other(s) => s.as_ref(), 252 } 253 } 254} 255 256impl<'a> From<&'a str> for CardSection<'a> { 257 fn from(s: &'a str) -> Self { 258 match s { 259 "mainboard" => Self::Mainboard, 260 "sideboard" => Self::Sideboard, 261 "maybeboard" => Self::Maybeboard, 262 "commander" => Self::Commander, 263 _ => Self::Other(jacquard_common::CowStr::from(s)), 264 } 265 } 266} 267 268impl<'a> From<String> for CardSection<'a> { 269 fn from(s: String) -> Self { 270 match s.as_str() { 271 "mainboard" => Self::Mainboard, 272 "sideboard" => Self::Sideboard, 273 "maybeboard" => Self::Maybeboard, 274 "commander" => Self::Commander, 275 _ => Self::Other(jacquard_common::CowStr::from(s)), 276 } 277 } 278} 279 280impl<'a> core::fmt::Display for CardSection<'a> { 281 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 282 write!(f, "{}", self.as_str()) 283 } 284} 285 286impl<'a> AsRef<str> for CardSection<'a> { 287 fn as_ref(&self) -> &str { 288 self.as_str() 289 } 290} 291 292impl<'a> serde::Serialize for CardSection<'a> { 293 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> 294 where 295 S: serde::Serializer, 296 { 297 serializer.serialize_str(self.as_str()) 298 } 299} 300 301impl<'de, 'a> serde::Deserialize<'de> for CardSection<'a> 302where 303 'de: 'a, 304{ 305 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> 306 where 307 D: serde::Deserializer<'de>, 308 { 309 let s = <&'de str>::deserialize(deserializer)?; 310 Ok(Self::from(s)) 311 } 312} 313 314impl<'a> Default for CardSection<'a> { 315 fn default() -> Self { 316 Self::Other(Default::default()) 317 } 318} 319 320impl jacquard_common::IntoStatic for CardSection<'_> { 321 type Output = CardSection<'static>; 322 fn into_static(self) -> Self::Output { 323 match self { 324 CardSection::Mainboard => CardSection::Mainboard, 325 CardSection::Sideboard => CardSection::Sideboard, 326 CardSection::Maybeboard => CardSection::Maybeboard, 327 CardSection::Commander => CardSection::Commander, 328 CardSection::Other(v) => CardSection::Other(v.into_static()), 329 } 330 } 331} 332 333fn lexicon_doc_com_deckbelcher_deck_list() -> ::jacquard_lexicon::lexicon::LexiconDoc< 334 'static, 335> { 336 ::jacquard_lexicon::lexicon::LexiconDoc { 337 lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, 338 id: ::jacquard_common::CowStr::new_static("com.deckbelcher.deck.list"), 339 revision: None, 340 description: None, 341 defs: { 342 let mut map = ::alloc::collections::BTreeMap::new(); 343 map.insert( 344 ::jacquard_common::smol_str::SmolStr::new_static("card"), 345 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 346 description: Some( 347 ::jacquard_common::CowStr::new_static( 348 "A card entry in a decklist.", 349 ), 350 ), 351 required: Some( 352 vec![ 353 ::jacquard_common::smol_str::SmolStr::new_static("scryfallId"), 354 ::jacquard_common::smol_str::SmolStr::new_static("quantity"), 355 ::jacquard_common::smol_str::SmolStr::new_static("section") 356 ], 357 ), 358 nullable: None, 359 properties: { 360 #[allow(unused_mut)] 361 let mut map = ::alloc::collections::BTreeMap::new(); 362 map.insert( 363 ::jacquard_common::smol_str::SmolStr::new_static("quantity"), 364 ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger { 365 description: None, 366 default: None, 367 minimum: Some(1i64), 368 maximum: None, 369 r#enum: None, 370 r#const: None, 371 }), 372 ); 373 map.insert( 374 ::jacquard_common::smol_str::SmolStr::new_static( 375 "scryfallId", 376 ), 377 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 378 description: Some( 379 ::jacquard_common::CowStr::new_static( 380 "Scryfall UUID for the specific printing.", 381 ), 382 ), 383 format: None, 384 default: None, 385 min_length: None, 386 max_length: None, 387 min_graphemes: None, 388 max_graphemes: None, 389 r#enum: None, 390 r#const: None, 391 known_values: None, 392 }), 393 ); 394 map.insert( 395 ::jacquard_common::smol_str::SmolStr::new_static("section"), 396 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 397 description: Some( 398 ::jacquard_common::CowStr::new_static( 399 "Which section of the deck this card belongs to. Extensible to support format-specific sections.", 400 ), 401 ), 402 format: None, 403 default: None, 404 min_length: None, 405 max_length: None, 406 min_graphemes: None, 407 max_graphemes: None, 408 r#enum: None, 409 r#const: None, 410 known_values: None, 411 }), 412 ); 413 map.insert( 414 ::jacquard_common::smol_str::SmolStr::new_static("tags"), 415 ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray { 416 description: Some( 417 ::jacquard_common::CowStr::new_static( 418 "User annotations for this card in this deck (e.g., \"removal\", \"wincon\", \"ramp\").", 419 ), 420 ), 421 items: ::jacquard_lexicon::lexicon::LexArrayItem::String(::jacquard_lexicon::lexicon::LexString { 422 description: Some( 423 ::jacquard_common::CowStr::new_static( 424 "A tag annotation for a card.", 425 ), 426 ), 427 format: None, 428 default: None, 429 min_length: None, 430 max_length: Some(640usize), 431 min_graphemes: None, 432 max_graphemes: Some(64usize), 433 r#enum: None, 434 r#const: None, 435 known_values: None, 436 }), 437 min_length: None, 438 max_length: Some(128usize), 439 }), 440 ); 441 map 442 }, 443 }), 444 ); 445 map.insert( 446 ::jacquard_common::smol_str::SmolStr::new_static("main"), 447 ::jacquard_lexicon::lexicon::LexUserType::Record(::jacquard_lexicon::lexicon::LexRecord { 448 description: Some( 449 ::jacquard_common::CowStr::new_static( 450 "A Magic: The Gathering decklist.", 451 ), 452 ), 453 key: Some(::jacquard_common::CowStr::new_static("tid")), 454 record: ::jacquard_lexicon::lexicon::LexRecordRecord::Object(::jacquard_lexicon::lexicon::LexObject { 455 description: None, 456 required: Some( 457 vec![ 458 ::jacquard_common::smol_str::SmolStr::new_static("name"), 459 ::jacquard_common::smol_str::SmolStr::new_static("cards"), 460 ::jacquard_common::smol_str::SmolStr::new_static("createdAt") 461 ], 462 ), 463 nullable: None, 464 properties: { 465 #[allow(unused_mut)] 466 let mut map = ::alloc::collections::BTreeMap::new(); 467 map.insert( 468 ::jacquard_common::smol_str::SmolStr::new_static("cards"), 469 ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray { 470 description: Some( 471 ::jacquard_common::CowStr::new_static( 472 "Array of cards in the decklist.", 473 ), 474 ), 475 items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef { 476 description: None, 477 r#ref: ::jacquard_common::CowStr::new_static("#card"), 478 }), 479 min_length: None, 480 max_length: None, 481 }), 482 ); 483 map.insert( 484 ::jacquard_common::smol_str::SmolStr::new_static( 485 "createdAt", 486 ), 487 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 488 description: Some( 489 ::jacquard_common::CowStr::new_static( 490 "Timestamp when the decklist was created.", 491 ), 492 ), 493 format: Some( 494 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime, 495 ), 496 default: None, 497 min_length: None, 498 max_length: None, 499 min_graphemes: None, 500 max_graphemes: None, 501 r#enum: None, 502 r#const: None, 503 known_values: None, 504 }), 505 ); 506 map.insert( 507 ::jacquard_common::smol_str::SmolStr::new_static("format"), 508 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 509 description: Some( 510 ::jacquard_common::CowStr::new_static( 511 "Format of the deck (e.g., \"commander\", \"cube\", \"pauper\").", 512 ), 513 ), 514 format: None, 515 default: None, 516 min_length: None, 517 max_length: Some(320usize), 518 min_graphemes: None, 519 max_graphemes: Some(32usize), 520 r#enum: None, 521 r#const: None, 522 known_values: None, 523 }), 524 ); 525 map.insert( 526 ::jacquard_common::smol_str::SmolStr::new_static("name"), 527 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 528 description: Some( 529 ::jacquard_common::CowStr::new_static( 530 "Name of the decklist.", 531 ), 532 ), 533 format: None, 534 default: None, 535 min_length: None, 536 max_length: Some(1280usize), 537 min_graphemes: None, 538 max_graphemes: Some(128usize), 539 r#enum: None, 540 r#const: None, 541 known_values: None, 542 }), 543 ); 544 map.insert( 545 ::jacquard_common::smol_str::SmolStr::new_static("primer"), 546 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 547 description: Some( 548 ::jacquard_common::CowStr::new_static( 549 "Deck primer with strategy, combos, and card choices.", 550 ), 551 ), 552 format: None, 553 default: None, 554 min_length: None, 555 max_length: Some(100000usize), 556 min_graphemes: None, 557 max_graphemes: Some(10000usize), 558 r#enum: None, 559 r#const: None, 560 known_values: None, 561 }), 562 ); 563 map.insert( 564 ::jacquard_common::smol_str::SmolStr::new_static( 565 "primerFacets", 566 ), 567 ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray { 568 description: Some( 569 ::jacquard_common::CowStr::new_static( 570 "Annotations of text in the primer (mentions, URLs, hashtags, card references, etc).", 571 ), 572 ), 573 items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef { 574 description: None, 575 r#ref: ::jacquard_common::CowStr::new_static( 576 "com.deckbelcher.richtext.facet", 577 ), 578 }), 579 min_length: None, 580 max_length: None, 581 }), 582 ); 583 map.insert( 584 ::jacquard_common::smol_str::SmolStr::new_static( 585 "updatedAt", 586 ), 587 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 588 description: Some( 589 ::jacquard_common::CowStr::new_static( 590 "Timestamp when the decklist was last updated.", 591 ), 592 ), 593 format: Some( 594 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime, 595 ), 596 default: None, 597 min_length: None, 598 max_length: None, 599 min_graphemes: None, 600 max_graphemes: None, 601 r#enum: None, 602 r#const: None, 603 known_values: None, 604 }), 605 ); 606 map 607 }, 608 }), 609 }), 610 ); 611 map 612 }, 613 } 614} 615 616impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Card<'a> { 617 fn nsid() -> &'static str { 618 "com.deckbelcher.deck.list" 619 } 620 fn def_name() -> &'static str { 621 "card" 622 } 623 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { 624 lexicon_doc_com_deckbelcher_deck_list() 625 } 626 fn validate( 627 &self, 628 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { 629 { 630 let value = &self.quantity; 631 if *value < 1i64 { 632 return Err(::jacquard_lexicon::validation::ConstraintError::Minimum { 633 path: ::jacquard_lexicon::validation::ValidationPath::from_field( 634 "quantity", 635 ), 636 min: 1i64, 637 actual: *value, 638 }); 639 } 640 } 641 if let Some(ref value) = self.tags { 642 #[allow(unused_comparisons)] 643 if value.len() > 128usize { 644 return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength { 645 path: ::jacquard_lexicon::validation::ValidationPath::from_field( 646 "tags", 647 ), 648 max: 128usize, 649 actual: value.len(), 650 }); 651 } 652 } 653 Ok(()) 654 } 655} 656 657/// A Magic: The Gathering decklist. 658#[jacquard_derive::lexicon] 659#[derive( 660 serde::Serialize, 661 serde::Deserialize, 662 Debug, 663 Clone, 664 PartialEq, 665 Eq, 666 jacquard_derive::IntoStatic 667)] 668#[serde(rename_all = "camelCase")] 669pub struct List<'a> { 670 /// Array of cards in the decklist. 671 #[serde(borrow)] 672 pub cards: Vec<crate::com_deckbelcher::deck::list::Card<'a>>, 673 /// Timestamp when the decklist was created. 674 pub created_at: jacquard_common::types::string::Datetime, 675 /// Format of the deck (e.g., "commander", "cube", "pauper"). 676 #[serde(skip_serializing_if = "std::option::Option::is_none")] 677 #[serde(borrow)] 678 pub format: std::option::Option<jacquard_common::CowStr<'a>>, 679 /// Name of the decklist. 680 #[serde(borrow)] 681 pub name: jacquard_common::CowStr<'a>, 682 /// Deck primer with strategy, combos, and card choices. 683 #[serde(skip_serializing_if = "std::option::Option::is_none")] 684 #[serde(borrow)] 685 pub primer: std::option::Option<jacquard_common::CowStr<'a>>, 686 /// Annotations of text in the primer (mentions, URLs, hashtags, card references, etc). 687 #[serde(skip_serializing_if = "std::option::Option::is_none")] 688 #[serde(borrow)] 689 pub primer_facets: std::option::Option< 690 Vec<crate::com_deckbelcher::richtext::facet::Facet<'a>>, 691 >, 692 /// Timestamp when the decklist was last updated. 693 #[serde(skip_serializing_if = "std::option::Option::is_none")] 694 pub updated_at: std::option::Option<jacquard_common::types::string::Datetime>, 695} 696 697pub mod list_state { 698 699 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 700 #[allow(unused)] 701 use ::core::marker::PhantomData; 702 mod sealed { 703 pub trait Sealed {} 704 } 705 /// State trait tracking which required fields have been set 706 pub trait State: sealed::Sealed { 707 type CreatedAt; 708 type Name; 709 type Cards; 710 } 711 /// Empty state - all required fields are unset 712 pub struct Empty(()); 713 impl sealed::Sealed for Empty {} 714 impl State for Empty { 715 type CreatedAt = Unset; 716 type Name = Unset; 717 type Cards = Unset; 718 } 719 ///State transition - sets the `created_at` field to Set 720 pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>); 721 impl<S: State> sealed::Sealed for SetCreatedAt<S> {} 722 impl<S: State> State for SetCreatedAt<S> { 723 type CreatedAt = Set<members::created_at>; 724 type Name = S::Name; 725 type Cards = S::Cards; 726 } 727 ///State transition - sets the `name` field to Set 728 pub struct SetName<S: State = Empty>(PhantomData<fn() -> S>); 729 impl<S: State> sealed::Sealed for SetName<S> {} 730 impl<S: State> State for SetName<S> { 731 type CreatedAt = S::CreatedAt; 732 type Name = Set<members::name>; 733 type Cards = S::Cards; 734 } 735 ///State transition - sets the `cards` field to Set 736 pub struct SetCards<S: State = Empty>(PhantomData<fn() -> S>); 737 impl<S: State> sealed::Sealed for SetCards<S> {} 738 impl<S: State> State for SetCards<S> { 739 type CreatedAt = S::CreatedAt; 740 type Name = S::Name; 741 type Cards = Set<members::cards>; 742 } 743 /// Marker types for field names 744 #[allow(non_camel_case_types)] 745 pub mod members { 746 ///Marker type for the `created_at` field 747 pub struct created_at(()); 748 ///Marker type for the `name` field 749 pub struct name(()); 750 ///Marker type for the `cards` field 751 pub struct cards(()); 752 } 753} 754 755/// Builder for constructing an instance of this type 756pub struct ListBuilder<'a, S: list_state::State> { 757 _phantom_state: ::core::marker::PhantomData<fn() -> S>, 758 __unsafe_private_named: ( 759 ::core::option::Option<Vec<crate::com_deckbelcher::deck::list::Card<'a>>>, 760 ::core::option::Option<jacquard_common::types::string::Datetime>, 761 ::core::option::Option<jacquard_common::CowStr<'a>>, 762 ::core::option::Option<jacquard_common::CowStr<'a>>, 763 ::core::option::Option<jacquard_common::CowStr<'a>>, 764 ::core::option::Option<Vec<crate::com_deckbelcher::richtext::facet::Facet<'a>>>, 765 ::core::option::Option<jacquard_common::types::string::Datetime>, 766 ), 767 _phantom: ::core::marker::PhantomData<&'a ()>, 768} 769 770impl<'a> List<'a> { 771 /// Create a new builder for this type 772 pub fn new() -> ListBuilder<'a, list_state::Empty> { 773 ListBuilder::new() 774 } 775} 776 777impl<'a> ListBuilder<'a, list_state::Empty> { 778 /// Create a new builder with all fields unset 779 pub fn new() -> Self { 780 ListBuilder { 781 _phantom_state: ::core::marker::PhantomData, 782 __unsafe_private_named: (None, None, None, None, None, None, None), 783 _phantom: ::core::marker::PhantomData, 784 } 785 } 786} 787 788impl<'a, S> ListBuilder<'a, S> 789where 790 S: list_state::State, 791 S::Cards: list_state::IsUnset, 792{ 793 /// Set the `cards` field (required) 794 pub fn cards( 795 mut self, 796 value: impl Into<Vec<crate::com_deckbelcher::deck::list::Card<'a>>>, 797 ) -> ListBuilder<'a, list_state::SetCards<S>> { 798 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); 799 ListBuilder { 800 _phantom_state: ::core::marker::PhantomData, 801 __unsafe_private_named: self.__unsafe_private_named, 802 _phantom: ::core::marker::PhantomData, 803 } 804 } 805} 806 807impl<'a, S> ListBuilder<'a, S> 808where 809 S: list_state::State, 810 S::CreatedAt: list_state::IsUnset, 811{ 812 /// Set the `createdAt` field (required) 813 pub fn created_at( 814 mut self, 815 value: impl Into<jacquard_common::types::string::Datetime>, 816 ) -> ListBuilder<'a, list_state::SetCreatedAt<S>> { 817 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); 818 ListBuilder { 819 _phantom_state: ::core::marker::PhantomData, 820 __unsafe_private_named: self.__unsafe_private_named, 821 _phantom: ::core::marker::PhantomData, 822 } 823 } 824} 825 826impl<'a, S: list_state::State> ListBuilder<'a, S> { 827 /// Set the `format` field (optional) 828 pub fn format( 829 mut self, 830 value: impl Into<Option<jacquard_common::CowStr<'a>>>, 831 ) -> Self { 832 self.__unsafe_private_named.2 = value.into(); 833 self 834 } 835 /// Set the `format` field to an Option value (optional) 836 pub fn maybe_format(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self { 837 self.__unsafe_private_named.2 = value; 838 self 839 } 840} 841 842impl<'a, S> ListBuilder<'a, S> 843where 844 S: list_state::State, 845 S::Name: list_state::IsUnset, 846{ 847 /// Set the `name` field (required) 848 pub fn name( 849 mut self, 850 value: impl Into<jacquard_common::CowStr<'a>>, 851 ) -> ListBuilder<'a, list_state::SetName<S>> { 852 self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into()); 853 ListBuilder { 854 _phantom_state: ::core::marker::PhantomData, 855 __unsafe_private_named: self.__unsafe_private_named, 856 _phantom: ::core::marker::PhantomData, 857 } 858 } 859} 860 861impl<'a, S: list_state::State> ListBuilder<'a, S> { 862 /// Set the `primer` field (optional) 863 pub fn primer( 864 mut self, 865 value: impl Into<Option<jacquard_common::CowStr<'a>>>, 866 ) -> Self { 867 self.__unsafe_private_named.4 = value.into(); 868 self 869 } 870 /// Set the `primer` field to an Option value (optional) 871 pub fn maybe_primer(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self { 872 self.__unsafe_private_named.4 = value; 873 self 874 } 875} 876 877impl<'a, S: list_state::State> ListBuilder<'a, S> { 878 /// Set the `primerFacets` field (optional) 879 pub fn primer_facets( 880 mut self, 881 value: impl Into<Option<Vec<crate::com_deckbelcher::richtext::facet::Facet<'a>>>>, 882 ) -> Self { 883 self.__unsafe_private_named.5 = value.into(); 884 self 885 } 886 /// Set the `primerFacets` field to an Option value (optional) 887 pub fn maybe_primer_facets( 888 mut self, 889 value: Option<Vec<crate::com_deckbelcher::richtext::facet::Facet<'a>>>, 890 ) -> Self { 891 self.__unsafe_private_named.5 = value; 892 self 893 } 894} 895 896impl<'a, S: list_state::State> ListBuilder<'a, S> { 897 /// Set the `updatedAt` field (optional) 898 pub fn updated_at( 899 mut self, 900 value: impl Into<Option<jacquard_common::types::string::Datetime>>, 901 ) -> Self { 902 self.__unsafe_private_named.6 = value.into(); 903 self 904 } 905 /// Set the `updatedAt` field to an Option value (optional) 906 pub fn maybe_updated_at( 907 mut self, 908 value: Option<jacquard_common::types::string::Datetime>, 909 ) -> Self { 910 self.__unsafe_private_named.6 = value; 911 self 912 } 913} 914 915impl<'a, S> ListBuilder<'a, S> 916where 917 S: list_state::State, 918 S::CreatedAt: list_state::IsSet, 919 S::Name: list_state::IsSet, 920 S::Cards: list_state::IsSet, 921{ 922 /// Build the final struct 923 pub fn build(self) -> List<'a> { 924 List { 925 cards: self.__unsafe_private_named.0.unwrap(), 926 created_at: self.__unsafe_private_named.1.unwrap(), 927 format: self.__unsafe_private_named.2, 928 name: self.__unsafe_private_named.3.unwrap(), 929 primer: self.__unsafe_private_named.4, 930 primer_facets: self.__unsafe_private_named.5, 931 updated_at: self.__unsafe_private_named.6, 932 extra_data: Default::default(), 933 } 934 } 935 /// Build the final struct with custom extra_data 936 pub fn build_with_data( 937 self, 938 extra_data: std::collections::BTreeMap< 939 jacquard_common::smol_str::SmolStr, 940 jacquard_common::types::value::Data<'a>, 941 >, 942 ) -> List<'a> { 943 List { 944 cards: self.__unsafe_private_named.0.unwrap(), 945 created_at: self.__unsafe_private_named.1.unwrap(), 946 format: self.__unsafe_private_named.2, 947 name: self.__unsafe_private_named.3.unwrap(), 948 primer: self.__unsafe_private_named.4, 949 primer_facets: self.__unsafe_private_named.5, 950 updated_at: self.__unsafe_private_named.6, 951 extra_data: Some(extra_data), 952 } 953 } 954} 955 956impl<'a> List<'a> { 957 pub fn uri( 958 uri: impl Into<jacquard_common::CowStr<'a>>, 959 ) -> Result< 960 jacquard_common::types::uri::RecordUri<'a, ListRecord>, 961 jacquard_common::types::uri::UriError, 962 > { 963 jacquard_common::types::uri::RecordUri::try_from_uri( 964 jacquard_common::types::string::AtUri::new_cow(uri.into())?, 965 ) 966 } 967} 968 969/// Typed wrapper for GetRecord response with this collection's record type. 970#[derive( 971 serde::Serialize, 972 serde::Deserialize, 973 Debug, 974 Clone, 975 PartialEq, 976 Eq, 977 jacquard_derive::IntoStatic 978)] 979#[serde(rename_all = "camelCase")] 980pub struct ListGetRecordOutput<'a> { 981 #[serde(skip_serializing_if = "std::option::Option::is_none")] 982 #[serde(borrow)] 983 pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>, 984 #[serde(borrow)] 985 pub uri: jacquard_common::types::string::AtUri<'a>, 986 #[serde(borrow)] 987 pub value: List<'a>, 988} 989 990impl From<ListGetRecordOutput<'_>> for List<'_> { 991 fn from(output: ListGetRecordOutput<'_>) -> Self { 992 use jacquard_common::IntoStatic; 993 output.value.into_static() 994 } 995} 996 997impl jacquard_common::types::collection::Collection for List<'_> { 998 const NSID: &'static str = "com.deckbelcher.deck.list"; 999 type Record = ListRecord; 1000} 1001 1002/// Marker type for deserializing records from this collection. 1003#[derive(Debug, serde::Serialize, serde::Deserialize)] 1004pub struct ListRecord; 1005impl jacquard_common::xrpc::XrpcResp for ListRecord { 1006 const NSID: &'static str = "com.deckbelcher.deck.list"; 1007 const ENCODING: &'static str = "application/json"; 1008 type Output<'de> = ListGetRecordOutput<'de>; 1009 type Err<'de> = jacquard_common::types::collection::RecordError<'de>; 1010} 1011 1012impl jacquard_common::types::collection::Collection for ListRecord { 1013 const NSID: &'static str = "com.deckbelcher.deck.list"; 1014 type Record = ListRecord; 1015} 1016 1017impl<'a> ::jacquard_lexicon::schema::LexiconSchema for List<'a> { 1018 fn nsid() -> &'static str { 1019 "com.deckbelcher.deck.list" 1020 } 1021 fn def_name() -> &'static str { 1022 "main" 1023 } 1024 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { 1025 lexicon_doc_com_deckbelcher_deck_list() 1026 } 1027 fn validate( 1028 &self, 1029 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { 1030 if let Some(ref value) = self.format { 1031 #[allow(unused_comparisons)] 1032 if <str>::len(value.as_ref()) > 320usize { 1033 return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength { 1034 path: ::jacquard_lexicon::validation::ValidationPath::from_field( 1035 "format", 1036 ), 1037 max: 320usize, 1038 actual: <str>::len(value.as_ref()), 1039 }); 1040 } 1041 } 1042 if let Some(ref value) = self.format { 1043 { 1044 let count = ::unicode_segmentation::UnicodeSegmentation::graphemes( 1045 value.as_ref(), 1046 true, 1047 ) 1048 .count(); 1049 if count > 32usize { 1050 return Err(::jacquard_lexicon::validation::ConstraintError::MaxGraphemes { 1051 path: ::jacquard_lexicon::validation::ValidationPath::from_field( 1052 "format", 1053 ), 1054 max: 32usize, 1055 actual: count, 1056 }); 1057 } 1058 } 1059 } 1060 { 1061 let value = &self.name; 1062 #[allow(unused_comparisons)] 1063 if <str>::len(value.as_ref()) > 1280usize { 1064 return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength { 1065 path: ::jacquard_lexicon::validation::ValidationPath::from_field( 1066 "name", 1067 ), 1068 max: 1280usize, 1069 actual: <str>::len(value.as_ref()), 1070 }); 1071 } 1072 } 1073 { 1074 let value = &self.name; 1075 { 1076 let count = ::unicode_segmentation::UnicodeSegmentation::graphemes( 1077 value.as_ref(), 1078 true, 1079 ) 1080 .count(); 1081 if count > 128usize { 1082 return Err(::jacquard_lexicon::validation::ConstraintError::MaxGraphemes { 1083 path: ::jacquard_lexicon::validation::ValidationPath::from_field( 1084 "name", 1085 ), 1086 max: 128usize, 1087 actual: count, 1088 }); 1089 } 1090 } 1091 } 1092 if let Some(ref value) = self.primer { 1093 #[allow(unused_comparisons)] 1094 if <str>::len(value.as_ref()) > 100000usize { 1095 return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength { 1096 path: ::jacquard_lexicon::validation::ValidationPath::from_field( 1097 "primer", 1098 ), 1099 max: 100000usize, 1100 actual: <str>::len(value.as_ref()), 1101 }); 1102 } 1103 } 1104 if let Some(ref value) = self.primer { 1105 { 1106 let count = ::unicode_segmentation::UnicodeSegmentation::graphemes( 1107 value.as_ref(), 1108 true, 1109 ) 1110 .count(); 1111 if count > 10000usize { 1112 return Err(::jacquard_lexicon::validation::ConstraintError::MaxGraphemes { 1113 path: ::jacquard_lexicon::validation::ValidationPath::from_field( 1114 "primer", 1115 ), 1116 max: 10000usize, 1117 actual: count, 1118 }); 1119 } 1120 } 1121 } 1122 Ok(()) 1123 } 1124}