this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 3610 lines 139 kB view raw
1// @generated by jacquard-lexicon. DO NOT EDIT. 2// 3// Lexicon: buzz.bookhive.defs 4// 5// This file was automatically generated from Lexicon schemas. 6// Any manual changes will be overwritten on the next regeneration. 7 8pub mod book; 9pub mod buzz; 10pub mod get_book; 11pub mod get_profile; 12pub mod hive_book; 13pub mod search_books; 14 15/// User has abandoned the book 16#[derive( 17 serde::Serialize, 18 serde::Deserialize, 19 Debug, 20 Clone, 21 PartialEq, 22 Eq, 23 Hash, 24 jacquard_derive::IntoStatic 25)] 26pub struct Abandoned; 27impl std::fmt::Display for Abandoned { 28 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 29 write!(f, "abandoned") 30 } 31} 32 33#[jacquard_derive::lexicon] 34#[derive( 35 serde::Serialize, 36 serde::Deserialize, 37 Debug, 38 Clone, 39 PartialEq, 40 Eq, 41 jacquard_derive::IntoStatic 42)] 43#[serde(rename_all = "camelCase")] 44pub struct Activity<'a> { 45 pub created_at: jacquard_common::types::string::Datetime, 46 /// The hive id of the book 47 #[serde(borrow)] 48 pub hive_id: jacquard_common::CowStr<'a>, 49 /// The title of the book 50 #[serde(borrow)] 51 pub title: jacquard_common::CowStr<'a>, 52 #[serde(borrow)] 53 pub r#type: ActivityType<'a>, 54 /// The DID of the user who added the book 55 #[serde(borrow)] 56 pub user_did: jacquard_common::CowStr<'a>, 57 /// The handle of the user who added the book 58 #[serde(borrow)] 59 pub user_handle: jacquard_common::CowStr<'a>, 60} 61 62pub mod activity_state { 63 64 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 65 #[allow(unused)] 66 use ::core::marker::PhantomData; 67 mod sealed { 68 pub trait Sealed {} 69 } 70 /// State trait tracking which required fields have been set 71 pub trait State: sealed::Sealed { 72 type UserDid; 73 type Title; 74 type UserHandle; 75 type CreatedAt; 76 type Type; 77 type HiveId; 78 } 79 /// Empty state - all required fields are unset 80 pub struct Empty(()); 81 impl sealed::Sealed for Empty {} 82 impl State for Empty { 83 type UserDid = Unset; 84 type Title = Unset; 85 type UserHandle = Unset; 86 type CreatedAt = Unset; 87 type Type = Unset; 88 type HiveId = Unset; 89 } 90 ///State transition - sets the `user_did` field to Set 91 pub struct SetUserDid<S: State = Empty>(PhantomData<fn() -> S>); 92 impl<S: State> sealed::Sealed for SetUserDid<S> {} 93 impl<S: State> State for SetUserDid<S> { 94 type UserDid = Set<members::user_did>; 95 type Title = S::Title; 96 type UserHandle = S::UserHandle; 97 type CreatedAt = S::CreatedAt; 98 type Type = S::Type; 99 type HiveId = S::HiveId; 100 } 101 ///State transition - sets the `title` field to Set 102 pub struct SetTitle<S: State = Empty>(PhantomData<fn() -> S>); 103 impl<S: State> sealed::Sealed for SetTitle<S> {} 104 impl<S: State> State for SetTitle<S> { 105 type UserDid = S::UserDid; 106 type Title = Set<members::title>; 107 type UserHandle = S::UserHandle; 108 type CreatedAt = S::CreatedAt; 109 type Type = S::Type; 110 type HiveId = S::HiveId; 111 } 112 ///State transition - sets the `user_handle` field to Set 113 pub struct SetUserHandle<S: State = Empty>(PhantomData<fn() -> S>); 114 impl<S: State> sealed::Sealed for SetUserHandle<S> {} 115 impl<S: State> State for SetUserHandle<S> { 116 type UserDid = S::UserDid; 117 type Title = S::Title; 118 type UserHandle = Set<members::user_handle>; 119 type CreatedAt = S::CreatedAt; 120 type Type = S::Type; 121 type HiveId = S::HiveId; 122 } 123 ///State transition - sets the `created_at` field to Set 124 pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>); 125 impl<S: State> sealed::Sealed for SetCreatedAt<S> {} 126 impl<S: State> State for SetCreatedAt<S> { 127 type UserDid = S::UserDid; 128 type Title = S::Title; 129 type UserHandle = S::UserHandle; 130 type CreatedAt = Set<members::created_at>; 131 type Type = S::Type; 132 type HiveId = S::HiveId; 133 } 134 ///State transition - sets the `type` field to Set 135 pub struct SetType<S: State = Empty>(PhantomData<fn() -> S>); 136 impl<S: State> sealed::Sealed for SetType<S> {} 137 impl<S: State> State for SetType<S> { 138 type UserDid = S::UserDid; 139 type Title = S::Title; 140 type UserHandle = S::UserHandle; 141 type CreatedAt = S::CreatedAt; 142 type Type = Set<members::r#type>; 143 type HiveId = S::HiveId; 144 } 145 ///State transition - sets the `hive_id` field to Set 146 pub struct SetHiveId<S: State = Empty>(PhantomData<fn() -> S>); 147 impl<S: State> sealed::Sealed for SetHiveId<S> {} 148 impl<S: State> State for SetHiveId<S> { 149 type UserDid = S::UserDid; 150 type Title = S::Title; 151 type UserHandle = S::UserHandle; 152 type CreatedAt = S::CreatedAt; 153 type Type = S::Type; 154 type HiveId = Set<members::hive_id>; 155 } 156 /// Marker types for field names 157 #[allow(non_camel_case_types)] 158 pub mod members { 159 ///Marker type for the `user_did` field 160 pub struct user_did(()); 161 ///Marker type for the `title` field 162 pub struct title(()); 163 ///Marker type for the `user_handle` field 164 pub struct user_handle(()); 165 ///Marker type for the `created_at` field 166 pub struct created_at(()); 167 ///Marker type for the `type` field 168 pub struct r#type(()); 169 ///Marker type for the `hive_id` field 170 pub struct hive_id(()); 171 } 172} 173 174/// Builder for constructing an instance of this type 175pub struct ActivityBuilder<'a, S: activity_state::State> { 176 _phantom_state: ::core::marker::PhantomData<fn() -> S>, 177 __unsafe_private_named: ( 178 ::core::option::Option<jacquard_common::types::string::Datetime>, 179 ::core::option::Option<jacquard_common::CowStr<'a>>, 180 ::core::option::Option<jacquard_common::CowStr<'a>>, 181 ::core::option::Option<ActivityType<'a>>, 182 ::core::option::Option<jacquard_common::CowStr<'a>>, 183 ::core::option::Option<jacquard_common::CowStr<'a>>, 184 ), 185 _phantom: ::core::marker::PhantomData<&'a ()>, 186} 187 188impl<'a> Activity<'a> { 189 /// Create a new builder for this type 190 pub fn new() -> ActivityBuilder<'a, activity_state::Empty> { 191 ActivityBuilder::new() 192 } 193} 194 195impl<'a> ActivityBuilder<'a, activity_state::Empty> { 196 /// Create a new builder with all fields unset 197 pub fn new() -> Self { 198 ActivityBuilder { 199 _phantom_state: ::core::marker::PhantomData, 200 __unsafe_private_named: (None, None, None, None, None, None), 201 _phantom: ::core::marker::PhantomData, 202 } 203 } 204} 205 206impl<'a, S> ActivityBuilder<'a, S> 207where 208 S: activity_state::State, 209 S::CreatedAt: activity_state::IsUnset, 210{ 211 /// Set the `createdAt` field (required) 212 pub fn created_at( 213 mut self, 214 value: impl Into<jacquard_common::types::string::Datetime>, 215 ) -> ActivityBuilder<'a, activity_state::SetCreatedAt<S>> { 216 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); 217 ActivityBuilder { 218 _phantom_state: ::core::marker::PhantomData, 219 __unsafe_private_named: self.__unsafe_private_named, 220 _phantom: ::core::marker::PhantomData, 221 } 222 } 223} 224 225impl<'a, S> ActivityBuilder<'a, S> 226where 227 S: activity_state::State, 228 S::HiveId: activity_state::IsUnset, 229{ 230 /// Set the `hiveId` field (required) 231 pub fn hive_id( 232 mut self, 233 value: impl Into<jacquard_common::CowStr<'a>>, 234 ) -> ActivityBuilder<'a, activity_state::SetHiveId<S>> { 235 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); 236 ActivityBuilder { 237 _phantom_state: ::core::marker::PhantomData, 238 __unsafe_private_named: self.__unsafe_private_named, 239 _phantom: ::core::marker::PhantomData, 240 } 241 } 242} 243 244impl<'a, S> ActivityBuilder<'a, S> 245where 246 S: activity_state::State, 247 S::Title: activity_state::IsUnset, 248{ 249 /// Set the `title` field (required) 250 pub fn title( 251 mut self, 252 value: impl Into<jacquard_common::CowStr<'a>>, 253 ) -> ActivityBuilder<'a, activity_state::SetTitle<S>> { 254 self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into()); 255 ActivityBuilder { 256 _phantom_state: ::core::marker::PhantomData, 257 __unsafe_private_named: self.__unsafe_private_named, 258 _phantom: ::core::marker::PhantomData, 259 } 260 } 261} 262 263impl<'a, S> ActivityBuilder<'a, S> 264where 265 S: activity_state::State, 266 S::Type: activity_state::IsUnset, 267{ 268 /// Set the `type` field (required) 269 pub fn r#type( 270 mut self, 271 value: impl Into<ActivityType<'a>>, 272 ) -> ActivityBuilder<'a, activity_state::SetType<S>> { 273 self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into()); 274 ActivityBuilder { 275 _phantom_state: ::core::marker::PhantomData, 276 __unsafe_private_named: self.__unsafe_private_named, 277 _phantom: ::core::marker::PhantomData, 278 } 279 } 280} 281 282impl<'a, S> ActivityBuilder<'a, S> 283where 284 S: activity_state::State, 285 S::UserDid: activity_state::IsUnset, 286{ 287 /// Set the `userDid` field (required) 288 pub fn user_did( 289 mut self, 290 value: impl Into<jacquard_common::CowStr<'a>>, 291 ) -> ActivityBuilder<'a, activity_state::SetUserDid<S>> { 292 self.__unsafe_private_named.4 = ::core::option::Option::Some(value.into()); 293 ActivityBuilder { 294 _phantom_state: ::core::marker::PhantomData, 295 __unsafe_private_named: self.__unsafe_private_named, 296 _phantom: ::core::marker::PhantomData, 297 } 298 } 299} 300 301impl<'a, S> ActivityBuilder<'a, S> 302where 303 S: activity_state::State, 304 S::UserHandle: activity_state::IsUnset, 305{ 306 /// Set the `userHandle` field (required) 307 pub fn user_handle( 308 mut self, 309 value: impl Into<jacquard_common::CowStr<'a>>, 310 ) -> ActivityBuilder<'a, activity_state::SetUserHandle<S>> { 311 self.__unsafe_private_named.5 = ::core::option::Option::Some(value.into()); 312 ActivityBuilder { 313 _phantom_state: ::core::marker::PhantomData, 314 __unsafe_private_named: self.__unsafe_private_named, 315 _phantom: ::core::marker::PhantomData, 316 } 317 } 318} 319 320impl<'a, S> ActivityBuilder<'a, S> 321where 322 S: activity_state::State, 323 S::UserDid: activity_state::IsSet, 324 S::Title: activity_state::IsSet, 325 S::UserHandle: activity_state::IsSet, 326 S::CreatedAt: activity_state::IsSet, 327 S::Type: activity_state::IsSet, 328 S::HiveId: activity_state::IsSet, 329{ 330 /// Build the final struct 331 pub fn build(self) -> Activity<'a> { 332 Activity { 333 created_at: self.__unsafe_private_named.0.unwrap(), 334 hive_id: self.__unsafe_private_named.1.unwrap(), 335 title: self.__unsafe_private_named.2.unwrap(), 336 r#type: self.__unsafe_private_named.3.unwrap(), 337 user_did: self.__unsafe_private_named.4.unwrap(), 338 user_handle: self.__unsafe_private_named.5.unwrap(), 339 extra_data: Default::default(), 340 } 341 } 342 /// Build the final struct with custom extra_data 343 pub fn build_with_data( 344 self, 345 extra_data: std::collections::BTreeMap< 346 jacquard_common::smol_str::SmolStr, 347 jacquard_common::types::value::Data<'a>, 348 >, 349 ) -> Activity<'a> { 350 Activity { 351 created_at: self.__unsafe_private_named.0.unwrap(), 352 hive_id: self.__unsafe_private_named.1.unwrap(), 353 title: self.__unsafe_private_named.2.unwrap(), 354 r#type: self.__unsafe_private_named.3.unwrap(), 355 user_did: self.__unsafe_private_named.4.unwrap(), 356 user_handle: self.__unsafe_private_named.5.unwrap(), 357 extra_data: Some(extra_data), 358 } 359 } 360} 361 362#[derive(Debug, Clone, PartialEq, Eq, Hash)] 363pub enum ActivityType<'a> { 364 Review, 365 Rated, 366 Started, 367 Finished, 368 Other(jacquard_common::CowStr<'a>), 369} 370 371impl<'a> ActivityType<'a> { 372 pub fn as_str(&self) -> &str { 373 match self { 374 Self::Review => "review", 375 Self::Rated => "rated", 376 Self::Started => "started", 377 Self::Finished => "finished", 378 Self::Other(s) => s.as_ref(), 379 } 380 } 381} 382 383impl<'a> From<&'a str> for ActivityType<'a> { 384 fn from(s: &'a str) -> Self { 385 match s { 386 "review" => Self::Review, 387 "rated" => Self::Rated, 388 "started" => Self::Started, 389 "finished" => Self::Finished, 390 _ => Self::Other(jacquard_common::CowStr::from(s)), 391 } 392 } 393} 394 395impl<'a> From<String> for ActivityType<'a> { 396 fn from(s: String) -> Self { 397 match s.as_str() { 398 "review" => Self::Review, 399 "rated" => Self::Rated, 400 "started" => Self::Started, 401 "finished" => Self::Finished, 402 _ => Self::Other(jacquard_common::CowStr::from(s)), 403 } 404 } 405} 406 407impl<'a> core::fmt::Display for ActivityType<'a> { 408 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 409 write!(f, "{}", self.as_str()) 410 } 411} 412 413impl<'a> AsRef<str> for ActivityType<'a> { 414 fn as_ref(&self) -> &str { 415 self.as_str() 416 } 417} 418 419impl<'a> serde::Serialize for ActivityType<'a> { 420 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> 421 where 422 S: serde::Serializer, 423 { 424 serializer.serialize_str(self.as_str()) 425 } 426} 427 428impl<'de, 'a> serde::Deserialize<'de> for ActivityType<'a> 429where 430 'de: 'a, 431{ 432 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> 433 where 434 D: serde::Deserializer<'de>, 435 { 436 let s = <&'de str>::deserialize(deserializer)?; 437 Ok(Self::from(s)) 438 } 439} 440 441impl<'a> Default for ActivityType<'a> { 442 fn default() -> Self { 443 Self::Other(Default::default()) 444 } 445} 446 447impl jacquard_common::IntoStatic for ActivityType<'_> { 448 type Output = ActivityType<'static>; 449 fn into_static(self) -> Self::Output { 450 match self { 451 ActivityType::Review => ActivityType::Review, 452 ActivityType::Rated => ActivityType::Rated, 453 ActivityType::Started => ActivityType::Started, 454 ActivityType::Finished => ActivityType::Finished, 455 ActivityType::Other(v) => ActivityType::Other(v.into_static()), 456 } 457 } 458} 459 460fn lexicon_doc_buzz_bookhive_defs() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { 461 ::jacquard_lexicon::lexicon::LexiconDoc { 462 lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, 463 id: ::jacquard_common::CowStr::new_static("buzz.bookhive.defs"), 464 revision: None, 465 description: None, 466 defs: { 467 let mut map = ::alloc::collections::BTreeMap::new(); 468 map.insert( 469 ::jacquard_common::smol_str::SmolStr::new_static("abandoned"), 470 ::jacquard_lexicon::lexicon::LexUserType::Token(::jacquard_lexicon::lexicon::LexToken { 471 description: None, 472 }), 473 ); 474 map.insert( 475 ::jacquard_common::smol_str::SmolStr::new_static("activity"), 476 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 477 description: None, 478 required: Some( 479 vec![ 480 ::jacquard_common::smol_str::SmolStr::new_static("type"), 481 ::jacquard_common::smol_str::SmolStr::new_static("createdAt"), 482 ::jacquard_common::smol_str::SmolStr::new_static("hiveId"), 483 ::jacquard_common::smol_str::SmolStr::new_static("title"), 484 ::jacquard_common::smol_str::SmolStr::new_static("userDid"), 485 ::jacquard_common::smol_str::SmolStr::new_static("userHandle") 486 ], 487 ), 488 nullable: None, 489 properties: { 490 #[allow(unused_mut)] 491 let mut map = ::alloc::collections::BTreeMap::new(); 492 map.insert( 493 ::jacquard_common::smol_str::SmolStr::new_static( 494 "createdAt", 495 ), 496 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 497 description: None, 498 format: Some( 499 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime, 500 ), 501 default: None, 502 min_length: None, 503 max_length: None, 504 min_graphemes: None, 505 max_graphemes: None, 506 r#enum: None, 507 r#const: None, 508 known_values: None, 509 }), 510 ); 511 map.insert( 512 ::jacquard_common::smol_str::SmolStr::new_static("hiveId"), 513 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 514 description: Some( 515 ::jacquard_common::CowStr::new_static( 516 "The hive id of the book", 517 ), 518 ), 519 format: None, 520 default: None, 521 min_length: None, 522 max_length: None, 523 min_graphemes: None, 524 max_graphemes: None, 525 r#enum: None, 526 r#const: None, 527 known_values: None, 528 }), 529 ); 530 map.insert( 531 ::jacquard_common::smol_str::SmolStr::new_static("title"), 532 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 533 description: Some( 534 ::jacquard_common::CowStr::new_static( 535 "The title of the book", 536 ), 537 ), 538 format: None, 539 default: None, 540 min_length: None, 541 max_length: None, 542 min_graphemes: None, 543 max_graphemes: None, 544 r#enum: None, 545 r#const: None, 546 known_values: None, 547 }), 548 ); 549 map.insert( 550 ::jacquard_common::smol_str::SmolStr::new_static("type"), 551 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 552 description: None, 553 format: None, 554 default: None, 555 min_length: None, 556 max_length: None, 557 min_graphemes: None, 558 max_graphemes: None, 559 r#enum: None, 560 r#const: None, 561 known_values: None, 562 }), 563 ); 564 map.insert( 565 ::jacquard_common::smol_str::SmolStr::new_static("userDid"), 566 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 567 description: Some( 568 ::jacquard_common::CowStr::new_static( 569 "The DID of the user who added the book", 570 ), 571 ), 572 format: None, 573 default: None, 574 min_length: None, 575 max_length: None, 576 min_graphemes: None, 577 max_graphemes: None, 578 r#enum: None, 579 r#const: None, 580 known_values: None, 581 }), 582 ); 583 map.insert( 584 ::jacquard_common::smol_str::SmolStr::new_static( 585 "userHandle", 586 ), 587 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 588 description: Some( 589 ::jacquard_common::CowStr::new_static( 590 "The handle of the user who added the book", 591 ), 592 ), 593 format: None, 594 default: None, 595 min_length: None, 596 max_length: None, 597 min_graphemes: None, 598 max_graphemes: None, 599 r#enum: None, 600 r#const: None, 601 known_values: None, 602 }), 603 ); 604 map 605 }, 606 }), 607 ); 608 map.insert( 609 ::jacquard_common::smol_str::SmolStr::new_static("bookProgress"), 610 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 611 description: Some( 612 ::jacquard_common::CowStr::new_static( 613 "Reading progress tracking data", 614 ), 615 ), 616 required: Some( 617 vec![ 618 ::jacquard_common::smol_str::SmolStr::new_static("updatedAt") 619 ], 620 ), 621 nullable: None, 622 properties: { 623 #[allow(unused_mut)] 624 let mut map = ::alloc::collections::BTreeMap::new(); 625 map.insert( 626 ::jacquard_common::smol_str::SmolStr::new_static( 627 "currentChapter", 628 ), 629 ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger { 630 description: None, 631 default: None, 632 minimum: Some(1i64), 633 maximum: None, 634 r#enum: None, 635 r#const: None, 636 }), 637 ); 638 map.insert( 639 ::jacquard_common::smol_str::SmolStr::new_static( 640 "currentPage", 641 ), 642 ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger { 643 description: None, 644 default: None, 645 minimum: Some(1i64), 646 maximum: None, 647 r#enum: None, 648 r#const: None, 649 }), 650 ); 651 map.insert( 652 ::jacquard_common::smol_str::SmolStr::new_static("percent"), 653 ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger { 654 description: None, 655 default: None, 656 minimum: Some(0i64), 657 maximum: Some(100i64), 658 r#enum: None, 659 r#const: None, 660 }), 661 ); 662 map.insert( 663 ::jacquard_common::smol_str::SmolStr::new_static( 664 "totalChapters", 665 ), 666 ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger { 667 description: None, 668 default: None, 669 minimum: Some(1i64), 670 maximum: None, 671 r#enum: None, 672 r#const: None, 673 }), 674 ); 675 map.insert( 676 ::jacquard_common::smol_str::SmolStr::new_static( 677 "totalPages", 678 ), 679 ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger { 680 description: None, 681 default: None, 682 minimum: Some(1i64), 683 maximum: None, 684 r#enum: None, 685 r#const: None, 686 }), 687 ); 688 map.insert( 689 ::jacquard_common::smol_str::SmolStr::new_static( 690 "updatedAt", 691 ), 692 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 693 description: Some( 694 ::jacquard_common::CowStr::new_static( 695 "When the progress was last updated", 696 ), 697 ), 698 format: Some( 699 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime, 700 ), 701 default: None, 702 min_length: None, 703 max_length: None, 704 min_graphemes: None, 705 max_graphemes: None, 706 r#enum: None, 707 r#const: None, 708 known_values: None, 709 }), 710 ); 711 map 712 }, 713 }), 714 ); 715 map.insert( 716 ::jacquard_common::smol_str::SmolStr::new_static("comment"), 717 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 718 description: None, 719 required: Some( 720 vec![ 721 ::jacquard_common::smol_str::SmolStr::new_static("comment"), 722 ::jacquard_common::smol_str::SmolStr::new_static("createdAt"), 723 ::jacquard_common::smol_str::SmolStr::new_static("book"), 724 ::jacquard_common::smol_str::SmolStr::new_static("parent"), 725 ::jacquard_common::smol_str::SmolStr::new_static("did"), 726 ::jacquard_common::smol_str::SmolStr::new_static("handle") 727 ], 728 ), 729 nullable: None, 730 properties: { 731 #[allow(unused_mut)] 732 let mut map = ::alloc::collections::BTreeMap::new(); 733 map.insert( 734 ::jacquard_common::smol_str::SmolStr::new_static("book"), 735 ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { 736 description: None, 737 r#ref: ::jacquard_common::CowStr::new_static( 738 "com.atproto.repo.strongRef", 739 ), 740 }), 741 ); 742 map.insert( 743 ::jacquard_common::smol_str::SmolStr::new_static("comment"), 744 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 745 description: Some( 746 ::jacquard_common::CowStr::new_static( 747 "The content of the comment.", 748 ), 749 ), 750 format: None, 751 default: None, 752 min_length: None, 753 max_length: Some(100000usize), 754 min_graphemes: None, 755 max_graphemes: Some(10000usize), 756 r#enum: None, 757 r#const: None, 758 known_values: None, 759 }), 760 ); 761 map.insert( 762 ::jacquard_common::smol_str::SmolStr::new_static( 763 "createdAt", 764 ), 765 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 766 description: Some( 767 ::jacquard_common::CowStr::new_static( 768 "Client-declared timestamp when this comment was originally created.", 769 ), 770 ), 771 format: Some( 772 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime, 773 ), 774 default: None, 775 min_length: None, 776 max_length: None, 777 min_graphemes: None, 778 max_graphemes: None, 779 r#enum: None, 780 r#const: None, 781 known_values: None, 782 }), 783 ); 784 map.insert( 785 ::jacquard_common::smol_str::SmolStr::new_static("did"), 786 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 787 description: Some( 788 ::jacquard_common::CowStr::new_static( 789 "The DID of the user who made the comment", 790 ), 791 ), 792 format: None, 793 default: None, 794 min_length: None, 795 max_length: None, 796 min_graphemes: None, 797 max_graphemes: None, 798 r#enum: None, 799 r#const: None, 800 known_values: None, 801 }), 802 ); 803 map.insert( 804 ::jacquard_common::smol_str::SmolStr::new_static("handle"), 805 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 806 description: Some( 807 ::jacquard_common::CowStr::new_static( 808 "The handle of the user who made the comment", 809 ), 810 ), 811 format: None, 812 default: None, 813 min_length: None, 814 max_length: None, 815 min_graphemes: None, 816 max_graphemes: None, 817 r#enum: None, 818 r#const: None, 819 known_values: None, 820 }), 821 ); 822 map.insert( 823 ::jacquard_common::smol_str::SmolStr::new_static("parent"), 824 ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { 825 description: None, 826 r#ref: ::jacquard_common::CowStr::new_static( 827 "com.atproto.repo.strongRef", 828 ), 829 }), 830 ); 831 map 832 }, 833 }), 834 ); 835 map.insert( 836 ::jacquard_common::smol_str::SmolStr::new_static("finished"), 837 ::jacquard_lexicon::lexicon::LexUserType::Token(::jacquard_lexicon::lexicon::LexToken { 838 description: None, 839 }), 840 ); 841 map.insert( 842 ::jacquard_common::smol_str::SmolStr::new_static("owned"), 843 ::jacquard_lexicon::lexicon::LexUserType::Token(::jacquard_lexicon::lexicon::LexToken { 844 description: None, 845 }), 846 ); 847 map.insert( 848 ::jacquard_common::smol_str::SmolStr::new_static("profile"), 849 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 850 description: None, 851 required: Some( 852 vec![ 853 ::jacquard_common::smol_str::SmolStr::new_static("displayName"), 854 ::jacquard_common::smol_str::SmolStr::new_static("handle"), 855 ::jacquard_common::smol_str::SmolStr::new_static("booksRead"), 856 ::jacquard_common::smol_str::SmolStr::new_static("reviews") 857 ], 858 ), 859 nullable: None, 860 properties: { 861 #[allow(unused_mut)] 862 let mut map = ::alloc::collections::BTreeMap::new(); 863 map.insert( 864 ::jacquard_common::smol_str::SmolStr::new_static("avatar"), 865 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 866 description: None, 867 format: None, 868 default: None, 869 min_length: None, 870 max_length: None, 871 min_graphemes: None, 872 max_graphemes: None, 873 r#enum: None, 874 r#const: None, 875 known_values: None, 876 }), 877 ); 878 map.insert( 879 ::jacquard_common::smol_str::SmolStr::new_static( 880 "booksRead", 881 ), 882 ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger { 883 description: None, 884 default: None, 885 minimum: Some(0i64), 886 maximum: None, 887 r#enum: None, 888 r#const: None, 889 }), 890 ); 891 map.insert( 892 ::jacquard_common::smol_str::SmolStr::new_static( 893 "description", 894 ), 895 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 896 description: None, 897 format: None, 898 default: None, 899 min_length: None, 900 max_length: None, 901 min_graphemes: None, 902 max_graphemes: None, 903 r#enum: None, 904 r#const: None, 905 known_values: None, 906 }), 907 ); 908 map.insert( 909 ::jacquard_common::smol_str::SmolStr::new_static( 910 "displayName", 911 ), 912 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 913 description: None, 914 format: None, 915 default: None, 916 min_length: None, 917 max_length: None, 918 min_graphemes: None, 919 max_graphemes: None, 920 r#enum: None, 921 r#const: None, 922 known_values: None, 923 }), 924 ); 925 map.insert( 926 ::jacquard_common::smol_str::SmolStr::new_static("handle"), 927 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 928 description: None, 929 format: None, 930 default: None, 931 min_length: None, 932 max_length: None, 933 min_graphemes: None, 934 max_graphemes: None, 935 r#enum: None, 936 r#const: None, 937 known_values: None, 938 }), 939 ); 940 map.insert( 941 ::jacquard_common::smol_str::SmolStr::new_static( 942 "isFollowing", 943 ), 944 ::jacquard_lexicon::lexicon::LexObjectProperty::Boolean(::jacquard_lexicon::lexicon::LexBoolean { 945 description: None, 946 default: None, 947 r#const: None, 948 }), 949 ); 950 map.insert( 951 ::jacquard_common::smol_str::SmolStr::new_static("reviews"), 952 ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger { 953 description: None, 954 default: None, 955 minimum: Some(0i64), 956 maximum: None, 957 r#enum: None, 958 r#const: None, 959 }), 960 ); 961 map 962 }, 963 }), 964 ); 965 map.insert( 966 ::jacquard_common::smol_str::SmolStr::new_static("reading"), 967 ::jacquard_lexicon::lexicon::LexUserType::Token(::jacquard_lexicon::lexicon::LexToken { 968 description: None, 969 }), 970 ); 971 map.insert( 972 ::jacquard_common::smol_str::SmolStr::new_static("review"), 973 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 974 description: None, 975 required: Some( 976 vec![ 977 ::jacquard_common::smol_str::SmolStr::new_static("review"), 978 ::jacquard_common::smol_str::SmolStr::new_static("createdAt"), 979 ::jacquard_common::smol_str::SmolStr::new_static("did"), 980 ::jacquard_common::smol_str::SmolStr::new_static("handle") 981 ], 982 ), 983 nullable: None, 984 properties: { 985 #[allow(unused_mut)] 986 let mut map = ::alloc::collections::BTreeMap::new(); 987 map.insert( 988 ::jacquard_common::smol_str::SmolStr::new_static( 989 "createdAt", 990 ), 991 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 992 description: Some( 993 ::jacquard_common::CowStr::new_static( 994 "The date the review was created", 995 ), 996 ), 997 format: Some( 998 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime, 999 ), 1000 default: None, 1001 min_length: None, 1002 max_length: None, 1003 min_graphemes: None, 1004 max_graphemes: None, 1005 r#enum: None, 1006 r#const: None, 1007 known_values: None, 1008 }), 1009 ); 1010 map.insert( 1011 ::jacquard_common::smol_str::SmolStr::new_static("did"), 1012 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 1013 description: Some( 1014 ::jacquard_common::CowStr::new_static( 1015 "The DID of the user who made the review", 1016 ), 1017 ), 1018 format: None, 1019 default: None, 1020 min_length: None, 1021 max_length: None, 1022 min_graphemes: None, 1023 max_graphemes: None, 1024 r#enum: None, 1025 r#const: None, 1026 known_values: None, 1027 }), 1028 ); 1029 map.insert( 1030 ::jacquard_common::smol_str::SmolStr::new_static("handle"), 1031 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 1032 description: Some( 1033 ::jacquard_common::CowStr::new_static( 1034 "The handle of the user who made the review", 1035 ), 1036 ), 1037 format: None, 1038 default: None, 1039 min_length: None, 1040 max_length: None, 1041 min_graphemes: None, 1042 max_graphemes: None, 1043 r#enum: None, 1044 r#const: None, 1045 known_values: None, 1046 }), 1047 ); 1048 map.insert( 1049 ::jacquard_common::smol_str::SmolStr::new_static("review"), 1050 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 1051 description: Some( 1052 ::jacquard_common::CowStr::new_static("The review content"), 1053 ), 1054 format: None, 1055 default: None, 1056 min_length: None, 1057 max_length: None, 1058 min_graphemes: None, 1059 max_graphemes: None, 1060 r#enum: None, 1061 r#const: None, 1062 known_values: None, 1063 }), 1064 ); 1065 map.insert( 1066 ::jacquard_common::smol_str::SmolStr::new_static("stars"), 1067 ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger { 1068 description: None, 1069 default: None, 1070 minimum: None, 1071 maximum: None, 1072 r#enum: None, 1073 r#const: None, 1074 }), 1075 ); 1076 map 1077 }, 1078 }), 1079 ); 1080 map.insert( 1081 ::jacquard_common::smol_str::SmolStr::new_static("userBook"), 1082 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 1083 description: None, 1084 required: Some( 1085 vec![ 1086 ::jacquard_common::smol_str::SmolStr::new_static("userDid"), 1087 ::jacquard_common::smol_str::SmolStr::new_static("title"), 1088 ::jacquard_common::smol_str::SmolStr::new_static("authors"), 1089 ::jacquard_common::smol_str::SmolStr::new_static("hiveId"), 1090 ::jacquard_common::smol_str::SmolStr::new_static("createdAt"), 1091 ::jacquard_common::smol_str::SmolStr::new_static("thumbnail") 1092 ], 1093 ), 1094 nullable: None, 1095 properties: { 1096 #[allow(unused_mut)] 1097 let mut map = ::alloc::collections::BTreeMap::new(); 1098 map.insert( 1099 ::jacquard_common::smol_str::SmolStr::new_static("authors"), 1100 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 1101 description: Some( 1102 ::jacquard_common::CowStr::new_static( 1103 "The authors of the book (tab separated)", 1104 ), 1105 ), 1106 format: None, 1107 default: None, 1108 min_length: Some(1usize), 1109 max_length: Some(2048usize), 1110 min_graphemes: None, 1111 max_graphemes: None, 1112 r#enum: None, 1113 r#const: None, 1114 known_values: None, 1115 }), 1116 ); 1117 map.insert( 1118 ::jacquard_common::smol_str::SmolStr::new_static( 1119 "bookProgress", 1120 ), 1121 ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { 1122 description: None, 1123 r#ref: ::jacquard_common::CowStr::new_static( 1124 "buzz.bookhive.defs#bookProgress", 1125 ), 1126 }), 1127 ); 1128 map.insert( 1129 ::jacquard_common::smol_str::SmolStr::new_static("cover"), 1130 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 1131 description: Some( 1132 ::jacquard_common::CowStr::new_static( 1133 "Cover image of the book", 1134 ), 1135 ), 1136 format: None, 1137 default: None, 1138 min_length: None, 1139 max_length: None, 1140 min_graphemes: None, 1141 max_graphemes: None, 1142 r#enum: None, 1143 r#const: None, 1144 known_values: None, 1145 }), 1146 ); 1147 map.insert( 1148 ::jacquard_common::smol_str::SmolStr::new_static( 1149 "createdAt", 1150 ), 1151 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 1152 description: None, 1153 format: Some( 1154 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime, 1155 ), 1156 default: None, 1157 min_length: None, 1158 max_length: None, 1159 min_graphemes: None, 1160 max_graphemes: None, 1161 r#enum: None, 1162 r#const: None, 1163 known_values: None, 1164 }), 1165 ); 1166 map.insert( 1167 ::jacquard_common::smol_str::SmolStr::new_static( 1168 "description", 1169 ), 1170 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 1171 description: Some( 1172 ::jacquard_common::CowStr::new_static( 1173 "Book description/summary", 1174 ), 1175 ), 1176 format: None, 1177 default: None, 1178 min_length: None, 1179 max_length: Some(5000usize), 1180 min_graphemes: None, 1181 max_graphemes: None, 1182 r#enum: None, 1183 r#const: None, 1184 known_values: None, 1185 }), 1186 ); 1187 map.insert( 1188 ::jacquard_common::smol_str::SmolStr::new_static( 1189 "finishedAt", 1190 ), 1191 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 1192 description: Some( 1193 ::jacquard_common::CowStr::new_static( 1194 "The date the user finished reading the book", 1195 ), 1196 ), 1197 format: Some( 1198 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime, 1199 ), 1200 default: None, 1201 min_length: None, 1202 max_length: None, 1203 min_graphemes: None, 1204 max_graphemes: None, 1205 r#enum: None, 1206 r#const: None, 1207 known_values: None, 1208 }), 1209 ); 1210 map.insert( 1211 ::jacquard_common::smol_str::SmolStr::new_static("hiveId"), 1212 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 1213 description: Some( 1214 ::jacquard_common::CowStr::new_static( 1215 "The book's hive id, used to correlate user's books with the hive", 1216 ), 1217 ), 1218 format: None, 1219 default: None, 1220 min_length: None, 1221 max_length: None, 1222 min_graphemes: None, 1223 max_graphemes: None, 1224 r#enum: None, 1225 r#const: None, 1226 known_values: None, 1227 }), 1228 ); 1229 map.insert( 1230 ::jacquard_common::smol_str::SmolStr::new_static("rating"), 1231 ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger { 1232 description: None, 1233 default: None, 1234 minimum: Some(0i64), 1235 maximum: Some(1000i64), 1236 r#enum: None, 1237 r#const: None, 1238 }), 1239 ); 1240 map.insert( 1241 ::jacquard_common::smol_str::SmolStr::new_static("review"), 1242 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 1243 description: Some( 1244 ::jacquard_common::CowStr::new_static("The book's review"), 1245 ), 1246 format: None, 1247 default: None, 1248 min_length: None, 1249 max_length: None, 1250 min_graphemes: None, 1251 max_graphemes: Some(15000usize), 1252 r#enum: None, 1253 r#const: None, 1254 known_values: None, 1255 }), 1256 ); 1257 map.insert( 1258 ::jacquard_common::smol_str::SmolStr::new_static("stars"), 1259 ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger { 1260 description: None, 1261 default: None, 1262 minimum: Some(1i64), 1263 maximum: Some(10i64), 1264 r#enum: None, 1265 r#const: None, 1266 }), 1267 ); 1268 map.insert( 1269 ::jacquard_common::smol_str::SmolStr::new_static( 1270 "startedAt", 1271 ), 1272 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 1273 description: Some( 1274 ::jacquard_common::CowStr::new_static( 1275 "The date the user started reading the book", 1276 ), 1277 ), 1278 format: Some( 1279 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime, 1280 ), 1281 default: None, 1282 min_length: None, 1283 max_length: None, 1284 min_graphemes: None, 1285 max_graphemes: None, 1286 r#enum: None, 1287 r#const: None, 1288 known_values: None, 1289 }), 1290 ); 1291 map.insert( 1292 ::jacquard_common::smol_str::SmolStr::new_static("status"), 1293 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 1294 description: None, 1295 format: None, 1296 default: None, 1297 min_length: None, 1298 max_length: None, 1299 min_graphemes: None, 1300 max_graphemes: None, 1301 r#enum: None, 1302 r#const: None, 1303 known_values: None, 1304 }), 1305 ); 1306 map.insert( 1307 ::jacquard_common::smol_str::SmolStr::new_static( 1308 "thumbnail", 1309 ), 1310 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 1311 description: Some( 1312 ::jacquard_common::CowStr::new_static( 1313 "Cover image of the book", 1314 ), 1315 ), 1316 format: None, 1317 default: None, 1318 min_length: None, 1319 max_length: None, 1320 min_graphemes: None, 1321 max_graphemes: None, 1322 r#enum: None, 1323 r#const: None, 1324 known_values: None, 1325 }), 1326 ); 1327 map.insert( 1328 ::jacquard_common::smol_str::SmolStr::new_static("title"), 1329 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 1330 description: Some( 1331 ::jacquard_common::CowStr::new_static( 1332 "The title of the book", 1333 ), 1334 ), 1335 format: None, 1336 default: None, 1337 min_length: Some(1usize), 1338 max_length: Some(512usize), 1339 min_graphemes: None, 1340 max_graphemes: None, 1341 r#enum: None, 1342 r#const: None, 1343 known_values: None, 1344 }), 1345 ); 1346 map.insert( 1347 ::jacquard_common::smol_str::SmolStr::new_static("userDid"), 1348 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 1349 description: Some( 1350 ::jacquard_common::CowStr::new_static( 1351 "The DID of the user who added the book", 1352 ), 1353 ), 1354 format: None, 1355 default: None, 1356 min_length: None, 1357 max_length: None, 1358 min_graphemes: None, 1359 max_graphemes: None, 1360 r#enum: None, 1361 r#const: None, 1362 known_values: None, 1363 }), 1364 ); 1365 map.insert( 1366 ::jacquard_common::smol_str::SmolStr::new_static( 1367 "userHandle", 1368 ), 1369 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 1370 description: Some( 1371 ::jacquard_common::CowStr::new_static( 1372 "The handle of the user who added the book", 1373 ), 1374 ), 1375 format: None, 1376 default: None, 1377 min_length: None, 1378 max_length: None, 1379 min_graphemes: None, 1380 max_graphemes: None, 1381 r#enum: None, 1382 r#const: None, 1383 known_values: None, 1384 }), 1385 ); 1386 map 1387 }, 1388 }), 1389 ); 1390 map.insert( 1391 ::jacquard_common::smol_str::SmolStr::new_static("wantToRead"), 1392 ::jacquard_lexicon::lexicon::LexUserType::Token(::jacquard_lexicon::lexicon::LexToken { 1393 description: None, 1394 }), 1395 ); 1396 map 1397 }, 1398 } 1399} 1400 1401impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Activity<'a> { 1402 fn nsid() -> &'static str { 1403 "buzz.bookhive.defs" 1404 } 1405 fn def_name() -> &'static str { 1406 "activity" 1407 } 1408 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { 1409 lexicon_doc_buzz_bookhive_defs() 1410 } 1411 fn validate( 1412 &self, 1413 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { 1414 Ok(()) 1415 } 1416} 1417 1418/// Reading progress tracking data 1419#[jacquard_derive::lexicon] 1420#[derive( 1421 serde::Serialize, 1422 serde::Deserialize, 1423 Debug, 1424 Clone, 1425 PartialEq, 1426 Eq, 1427 jacquard_derive::IntoStatic 1428)] 1429#[serde(rename_all = "camelCase")] 1430pub struct BookProgress<'a> { 1431 /// Current chapter the user is on 1432 #[serde(skip_serializing_if = "std::option::Option::is_none")] 1433 pub current_chapter: std::option::Option<i64>, 1434 /// Current page the user is on 1435 #[serde(skip_serializing_if = "std::option::Option::is_none")] 1436 pub current_page: std::option::Option<i64>, 1437 /// How far through the book the reader is (0-100) 1438 #[serde(skip_serializing_if = "std::option::Option::is_none")] 1439 pub percent: std::option::Option<i64>, 1440 /// Total number of chapters in the book 1441 #[serde(skip_serializing_if = "std::option::Option::is_none")] 1442 pub total_chapters: std::option::Option<i64>, 1443 /// Total number of pages in the book 1444 #[serde(skip_serializing_if = "std::option::Option::is_none")] 1445 pub total_pages: std::option::Option<i64>, 1446 /// When the progress was last updated 1447 pub updated_at: jacquard_common::types::string::Datetime, 1448} 1449 1450pub mod book_progress_state { 1451 1452 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 1453 #[allow(unused)] 1454 use ::core::marker::PhantomData; 1455 mod sealed { 1456 pub trait Sealed {} 1457 } 1458 /// State trait tracking which required fields have been set 1459 pub trait State: sealed::Sealed { 1460 type UpdatedAt; 1461 } 1462 /// Empty state - all required fields are unset 1463 pub struct Empty(()); 1464 impl sealed::Sealed for Empty {} 1465 impl State for Empty { 1466 type UpdatedAt = Unset; 1467 } 1468 ///State transition - sets the `updated_at` field to Set 1469 pub struct SetUpdatedAt<S: State = Empty>(PhantomData<fn() -> S>); 1470 impl<S: State> sealed::Sealed for SetUpdatedAt<S> {} 1471 impl<S: State> State for SetUpdatedAt<S> { 1472 type UpdatedAt = Set<members::updated_at>; 1473 } 1474 /// Marker types for field names 1475 #[allow(non_camel_case_types)] 1476 pub mod members { 1477 ///Marker type for the `updated_at` field 1478 pub struct updated_at(()); 1479 } 1480} 1481 1482/// Builder for constructing an instance of this type 1483pub struct BookProgressBuilder<'a, S: book_progress_state::State> { 1484 _phantom_state: ::core::marker::PhantomData<fn() -> S>, 1485 __unsafe_private_named: ( 1486 ::core::option::Option<i64>, 1487 ::core::option::Option<i64>, 1488 ::core::option::Option<i64>, 1489 ::core::option::Option<i64>, 1490 ::core::option::Option<i64>, 1491 ::core::option::Option<jacquard_common::types::string::Datetime>, 1492 ), 1493 _phantom: ::core::marker::PhantomData<&'a ()>, 1494} 1495 1496impl<'a> BookProgress<'a> { 1497 /// Create a new builder for this type 1498 pub fn new() -> BookProgressBuilder<'a, book_progress_state::Empty> { 1499 BookProgressBuilder::new() 1500 } 1501} 1502 1503impl<'a> BookProgressBuilder<'a, book_progress_state::Empty> { 1504 /// Create a new builder with all fields unset 1505 pub fn new() -> Self { 1506 BookProgressBuilder { 1507 _phantom_state: ::core::marker::PhantomData, 1508 __unsafe_private_named: (None, None, None, None, None, None), 1509 _phantom: ::core::marker::PhantomData, 1510 } 1511 } 1512} 1513 1514impl<'a, S: book_progress_state::State> BookProgressBuilder<'a, S> { 1515 /// Set the `currentChapter` field (optional) 1516 pub fn current_chapter(mut self, value: impl Into<Option<i64>>) -> Self { 1517 self.__unsafe_private_named.0 = value.into(); 1518 self 1519 } 1520 /// Set the `currentChapter` field to an Option value (optional) 1521 pub fn maybe_current_chapter(mut self, value: Option<i64>) -> Self { 1522 self.__unsafe_private_named.0 = value; 1523 self 1524 } 1525} 1526 1527impl<'a, S: book_progress_state::State> BookProgressBuilder<'a, S> { 1528 /// Set the `currentPage` field (optional) 1529 pub fn current_page(mut self, value: impl Into<Option<i64>>) -> Self { 1530 self.__unsafe_private_named.1 = value.into(); 1531 self 1532 } 1533 /// Set the `currentPage` field to an Option value (optional) 1534 pub fn maybe_current_page(mut self, value: Option<i64>) -> Self { 1535 self.__unsafe_private_named.1 = value; 1536 self 1537 } 1538} 1539 1540impl<'a, S: book_progress_state::State> BookProgressBuilder<'a, S> { 1541 /// Set the `percent` field (optional) 1542 pub fn percent(mut self, value: impl Into<Option<i64>>) -> Self { 1543 self.__unsafe_private_named.2 = value.into(); 1544 self 1545 } 1546 /// Set the `percent` field to an Option value (optional) 1547 pub fn maybe_percent(mut self, value: Option<i64>) -> Self { 1548 self.__unsafe_private_named.2 = value; 1549 self 1550 } 1551} 1552 1553impl<'a, S: book_progress_state::State> BookProgressBuilder<'a, S> { 1554 /// Set the `totalChapters` field (optional) 1555 pub fn total_chapters(mut self, value: impl Into<Option<i64>>) -> Self { 1556 self.__unsafe_private_named.3 = value.into(); 1557 self 1558 } 1559 /// Set the `totalChapters` field to an Option value (optional) 1560 pub fn maybe_total_chapters(mut self, value: Option<i64>) -> Self { 1561 self.__unsafe_private_named.3 = value; 1562 self 1563 } 1564} 1565 1566impl<'a, S: book_progress_state::State> BookProgressBuilder<'a, S> { 1567 /// Set the `totalPages` field (optional) 1568 pub fn total_pages(mut self, value: impl Into<Option<i64>>) -> Self { 1569 self.__unsafe_private_named.4 = value.into(); 1570 self 1571 } 1572 /// Set the `totalPages` field to an Option value (optional) 1573 pub fn maybe_total_pages(mut self, value: Option<i64>) -> Self { 1574 self.__unsafe_private_named.4 = value; 1575 self 1576 } 1577} 1578 1579impl<'a, S> BookProgressBuilder<'a, S> 1580where 1581 S: book_progress_state::State, 1582 S::UpdatedAt: book_progress_state::IsUnset, 1583{ 1584 /// Set the `updatedAt` field (required) 1585 pub fn updated_at( 1586 mut self, 1587 value: impl Into<jacquard_common::types::string::Datetime>, 1588 ) -> BookProgressBuilder<'a, book_progress_state::SetUpdatedAt<S>> { 1589 self.__unsafe_private_named.5 = ::core::option::Option::Some(value.into()); 1590 BookProgressBuilder { 1591 _phantom_state: ::core::marker::PhantomData, 1592 __unsafe_private_named: self.__unsafe_private_named, 1593 _phantom: ::core::marker::PhantomData, 1594 } 1595 } 1596} 1597 1598impl<'a, S> BookProgressBuilder<'a, S> 1599where 1600 S: book_progress_state::State, 1601 S::UpdatedAt: book_progress_state::IsSet, 1602{ 1603 /// Build the final struct 1604 pub fn build(self) -> BookProgress<'a> { 1605 BookProgress { 1606 current_chapter: self.__unsafe_private_named.0, 1607 current_page: self.__unsafe_private_named.1, 1608 percent: self.__unsafe_private_named.2, 1609 total_chapters: self.__unsafe_private_named.3, 1610 total_pages: self.__unsafe_private_named.4, 1611 updated_at: self.__unsafe_private_named.5.unwrap(), 1612 extra_data: Default::default(), 1613 } 1614 } 1615 /// Build the final struct with custom extra_data 1616 pub fn build_with_data( 1617 self, 1618 extra_data: std::collections::BTreeMap< 1619 jacquard_common::smol_str::SmolStr, 1620 jacquard_common::types::value::Data<'a>, 1621 >, 1622 ) -> BookProgress<'a> { 1623 BookProgress { 1624 current_chapter: self.__unsafe_private_named.0, 1625 current_page: self.__unsafe_private_named.1, 1626 percent: self.__unsafe_private_named.2, 1627 total_chapters: self.__unsafe_private_named.3, 1628 total_pages: self.__unsafe_private_named.4, 1629 updated_at: self.__unsafe_private_named.5.unwrap(), 1630 extra_data: Some(extra_data), 1631 } 1632 } 1633} 1634 1635impl<'a> ::jacquard_lexicon::schema::LexiconSchema for BookProgress<'a> { 1636 fn nsid() -> &'static str { 1637 "buzz.bookhive.defs" 1638 } 1639 fn def_name() -> &'static str { 1640 "bookProgress" 1641 } 1642 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { 1643 lexicon_doc_buzz_bookhive_defs() 1644 } 1645 fn validate( 1646 &self, 1647 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { 1648 if let Some(ref value) = self.current_chapter { 1649 if *value < 1i64 { 1650 return Err(::jacquard_lexicon::validation::ConstraintError::Minimum { 1651 path: ::jacquard_lexicon::validation::ValidationPath::from_field( 1652 "current_chapter", 1653 ), 1654 min: 1i64, 1655 actual: *value, 1656 }); 1657 } 1658 } 1659 if let Some(ref value) = self.current_page { 1660 if *value < 1i64 { 1661 return Err(::jacquard_lexicon::validation::ConstraintError::Minimum { 1662 path: ::jacquard_lexicon::validation::ValidationPath::from_field( 1663 "current_page", 1664 ), 1665 min: 1i64, 1666 actual: *value, 1667 }); 1668 } 1669 } 1670 if let Some(ref value) = self.percent { 1671 if *value > 100i64 { 1672 return Err(::jacquard_lexicon::validation::ConstraintError::Maximum { 1673 path: ::jacquard_lexicon::validation::ValidationPath::from_field( 1674 "percent", 1675 ), 1676 max: 100i64, 1677 actual: *value, 1678 }); 1679 } 1680 } 1681 if let Some(ref value) = self.percent { 1682 if *value < 0i64 { 1683 return Err(::jacquard_lexicon::validation::ConstraintError::Minimum { 1684 path: ::jacquard_lexicon::validation::ValidationPath::from_field( 1685 "percent", 1686 ), 1687 min: 0i64, 1688 actual: *value, 1689 }); 1690 } 1691 } 1692 if let Some(ref value) = self.total_chapters { 1693 if *value < 1i64 { 1694 return Err(::jacquard_lexicon::validation::ConstraintError::Minimum { 1695 path: ::jacquard_lexicon::validation::ValidationPath::from_field( 1696 "total_chapters", 1697 ), 1698 min: 1i64, 1699 actual: *value, 1700 }); 1701 } 1702 } 1703 if let Some(ref value) = self.total_pages { 1704 if *value < 1i64 { 1705 return Err(::jacquard_lexicon::validation::ConstraintError::Minimum { 1706 path: ::jacquard_lexicon::validation::ValidationPath::from_field( 1707 "total_pages", 1708 ), 1709 min: 1i64, 1710 actual: *value, 1711 }); 1712 } 1713 } 1714 Ok(()) 1715 } 1716} 1717 1718#[jacquard_derive::lexicon] 1719#[derive( 1720 serde::Serialize, 1721 serde::Deserialize, 1722 Debug, 1723 Clone, 1724 PartialEq, 1725 Eq, 1726 jacquard_derive::IntoStatic 1727)] 1728#[serde(rename_all = "camelCase")] 1729pub struct Comment<'a> { 1730 #[serde(borrow)] 1731 pub book: crate::com_atproto::repo::strong_ref::StrongRef<'a>, 1732 /// The content of the comment. 1733 #[serde(borrow)] 1734 pub comment: jacquard_common::CowStr<'a>, 1735 /// Client-declared timestamp when this comment was originally created. 1736 pub created_at: jacquard_common::types::string::Datetime, 1737 /// The DID of the user who made the comment 1738 #[serde(borrow)] 1739 pub did: jacquard_common::CowStr<'a>, 1740 /// The handle of the user who made the comment 1741 #[serde(borrow)] 1742 pub handle: jacquard_common::CowStr<'a>, 1743 #[serde(borrow)] 1744 pub parent: crate::com_atproto::repo::strong_ref::StrongRef<'a>, 1745} 1746 1747pub mod comment_state { 1748 1749 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 1750 #[allow(unused)] 1751 use ::core::marker::PhantomData; 1752 mod sealed { 1753 pub trait Sealed {} 1754 } 1755 /// State trait tracking which required fields have been set 1756 pub trait State: sealed::Sealed { 1757 type Did; 1758 type Handle; 1759 type Comment; 1760 type CreatedAt; 1761 type Book; 1762 type Parent; 1763 } 1764 /// Empty state - all required fields are unset 1765 pub struct Empty(()); 1766 impl sealed::Sealed for Empty {} 1767 impl State for Empty { 1768 type Did = Unset; 1769 type Handle = Unset; 1770 type Comment = Unset; 1771 type CreatedAt = Unset; 1772 type Book = Unset; 1773 type Parent = Unset; 1774 } 1775 ///State transition - sets the `did` field to Set 1776 pub struct SetDid<S: State = Empty>(PhantomData<fn() -> S>); 1777 impl<S: State> sealed::Sealed for SetDid<S> {} 1778 impl<S: State> State for SetDid<S> { 1779 type Did = Set<members::did>; 1780 type Handle = S::Handle; 1781 type Comment = S::Comment; 1782 type CreatedAt = S::CreatedAt; 1783 type Book = S::Book; 1784 type Parent = S::Parent; 1785 } 1786 ///State transition - sets the `handle` field to Set 1787 pub struct SetHandle<S: State = Empty>(PhantomData<fn() -> S>); 1788 impl<S: State> sealed::Sealed for SetHandle<S> {} 1789 impl<S: State> State for SetHandle<S> { 1790 type Did = S::Did; 1791 type Handle = Set<members::handle>; 1792 type Comment = S::Comment; 1793 type CreatedAt = S::CreatedAt; 1794 type Book = S::Book; 1795 type Parent = S::Parent; 1796 } 1797 ///State transition - sets the `comment` field to Set 1798 pub struct SetComment<S: State = Empty>(PhantomData<fn() -> S>); 1799 impl<S: State> sealed::Sealed for SetComment<S> {} 1800 impl<S: State> State for SetComment<S> { 1801 type Did = S::Did; 1802 type Handle = S::Handle; 1803 type Comment = Set<members::comment>; 1804 type CreatedAt = S::CreatedAt; 1805 type Book = S::Book; 1806 type Parent = S::Parent; 1807 } 1808 ///State transition - sets the `created_at` field to Set 1809 pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>); 1810 impl<S: State> sealed::Sealed for SetCreatedAt<S> {} 1811 impl<S: State> State for SetCreatedAt<S> { 1812 type Did = S::Did; 1813 type Handle = S::Handle; 1814 type Comment = S::Comment; 1815 type CreatedAt = Set<members::created_at>; 1816 type Book = S::Book; 1817 type Parent = S::Parent; 1818 } 1819 ///State transition - sets the `book` field to Set 1820 pub struct SetBook<S: State = Empty>(PhantomData<fn() -> S>); 1821 impl<S: State> sealed::Sealed for SetBook<S> {} 1822 impl<S: State> State for SetBook<S> { 1823 type Did = S::Did; 1824 type Handle = S::Handle; 1825 type Comment = S::Comment; 1826 type CreatedAt = S::CreatedAt; 1827 type Book = Set<members::book>; 1828 type Parent = S::Parent; 1829 } 1830 ///State transition - sets the `parent` field to Set 1831 pub struct SetParent<S: State = Empty>(PhantomData<fn() -> S>); 1832 impl<S: State> sealed::Sealed for SetParent<S> {} 1833 impl<S: State> State for SetParent<S> { 1834 type Did = S::Did; 1835 type Handle = S::Handle; 1836 type Comment = S::Comment; 1837 type CreatedAt = S::CreatedAt; 1838 type Book = S::Book; 1839 type Parent = Set<members::parent>; 1840 } 1841 /// Marker types for field names 1842 #[allow(non_camel_case_types)] 1843 pub mod members { 1844 ///Marker type for the `did` field 1845 pub struct did(()); 1846 ///Marker type for the `handle` field 1847 pub struct handle(()); 1848 ///Marker type for the `comment` field 1849 pub struct comment(()); 1850 ///Marker type for the `created_at` field 1851 pub struct created_at(()); 1852 ///Marker type for the `book` field 1853 pub struct book(()); 1854 ///Marker type for the `parent` field 1855 pub struct parent(()); 1856 } 1857} 1858 1859/// Builder for constructing an instance of this type 1860pub struct CommentBuilder<'a, S: comment_state::State> { 1861 _phantom_state: ::core::marker::PhantomData<fn() -> S>, 1862 __unsafe_private_named: ( 1863 ::core::option::Option<crate::com_atproto::repo::strong_ref::StrongRef<'a>>, 1864 ::core::option::Option<jacquard_common::CowStr<'a>>, 1865 ::core::option::Option<jacquard_common::types::string::Datetime>, 1866 ::core::option::Option<jacquard_common::CowStr<'a>>, 1867 ::core::option::Option<jacquard_common::CowStr<'a>>, 1868 ::core::option::Option<crate::com_atproto::repo::strong_ref::StrongRef<'a>>, 1869 ), 1870 _phantom: ::core::marker::PhantomData<&'a ()>, 1871} 1872 1873impl<'a> Comment<'a> { 1874 /// Create a new builder for this type 1875 pub fn new() -> CommentBuilder<'a, comment_state::Empty> { 1876 CommentBuilder::new() 1877 } 1878} 1879 1880impl<'a> CommentBuilder<'a, comment_state::Empty> { 1881 /// Create a new builder with all fields unset 1882 pub fn new() -> Self { 1883 CommentBuilder { 1884 _phantom_state: ::core::marker::PhantomData, 1885 __unsafe_private_named: (None, None, None, None, None, None), 1886 _phantom: ::core::marker::PhantomData, 1887 } 1888 } 1889} 1890 1891impl<'a, S> CommentBuilder<'a, S> 1892where 1893 S: comment_state::State, 1894 S::Book: comment_state::IsUnset, 1895{ 1896 /// Set the `book` field (required) 1897 pub fn book( 1898 mut self, 1899 value: impl Into<crate::com_atproto::repo::strong_ref::StrongRef<'a>>, 1900 ) -> CommentBuilder<'a, comment_state::SetBook<S>> { 1901 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); 1902 CommentBuilder { 1903 _phantom_state: ::core::marker::PhantomData, 1904 __unsafe_private_named: self.__unsafe_private_named, 1905 _phantom: ::core::marker::PhantomData, 1906 } 1907 } 1908} 1909 1910impl<'a, S> CommentBuilder<'a, S> 1911where 1912 S: comment_state::State, 1913 S::Comment: comment_state::IsUnset, 1914{ 1915 /// Set the `comment` field (required) 1916 pub fn comment( 1917 mut self, 1918 value: impl Into<jacquard_common::CowStr<'a>>, 1919 ) -> CommentBuilder<'a, comment_state::SetComment<S>> { 1920 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); 1921 CommentBuilder { 1922 _phantom_state: ::core::marker::PhantomData, 1923 __unsafe_private_named: self.__unsafe_private_named, 1924 _phantom: ::core::marker::PhantomData, 1925 } 1926 } 1927} 1928 1929impl<'a, S> CommentBuilder<'a, S> 1930where 1931 S: comment_state::State, 1932 S::CreatedAt: comment_state::IsUnset, 1933{ 1934 /// Set the `createdAt` field (required) 1935 pub fn created_at( 1936 mut self, 1937 value: impl Into<jacquard_common::types::string::Datetime>, 1938 ) -> CommentBuilder<'a, comment_state::SetCreatedAt<S>> { 1939 self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into()); 1940 CommentBuilder { 1941 _phantom_state: ::core::marker::PhantomData, 1942 __unsafe_private_named: self.__unsafe_private_named, 1943 _phantom: ::core::marker::PhantomData, 1944 } 1945 } 1946} 1947 1948impl<'a, S> CommentBuilder<'a, S> 1949where 1950 S: comment_state::State, 1951 S::Did: comment_state::IsUnset, 1952{ 1953 /// Set the `did` field (required) 1954 pub fn did( 1955 mut self, 1956 value: impl Into<jacquard_common::CowStr<'a>>, 1957 ) -> CommentBuilder<'a, comment_state::SetDid<S>> { 1958 self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into()); 1959 CommentBuilder { 1960 _phantom_state: ::core::marker::PhantomData, 1961 __unsafe_private_named: self.__unsafe_private_named, 1962 _phantom: ::core::marker::PhantomData, 1963 } 1964 } 1965} 1966 1967impl<'a, S> CommentBuilder<'a, S> 1968where 1969 S: comment_state::State, 1970 S::Handle: comment_state::IsUnset, 1971{ 1972 /// Set the `handle` field (required) 1973 pub fn handle( 1974 mut self, 1975 value: impl Into<jacquard_common::CowStr<'a>>, 1976 ) -> CommentBuilder<'a, comment_state::SetHandle<S>> { 1977 self.__unsafe_private_named.4 = ::core::option::Option::Some(value.into()); 1978 CommentBuilder { 1979 _phantom_state: ::core::marker::PhantomData, 1980 __unsafe_private_named: self.__unsafe_private_named, 1981 _phantom: ::core::marker::PhantomData, 1982 } 1983 } 1984} 1985 1986impl<'a, S> CommentBuilder<'a, S> 1987where 1988 S: comment_state::State, 1989 S::Parent: comment_state::IsUnset, 1990{ 1991 /// Set the `parent` field (required) 1992 pub fn parent( 1993 mut self, 1994 value: impl Into<crate::com_atproto::repo::strong_ref::StrongRef<'a>>, 1995 ) -> CommentBuilder<'a, comment_state::SetParent<S>> { 1996 self.__unsafe_private_named.5 = ::core::option::Option::Some(value.into()); 1997 CommentBuilder { 1998 _phantom_state: ::core::marker::PhantomData, 1999 __unsafe_private_named: self.__unsafe_private_named, 2000 _phantom: ::core::marker::PhantomData, 2001 } 2002 } 2003} 2004 2005impl<'a, S> CommentBuilder<'a, S> 2006where 2007 S: comment_state::State, 2008 S::Did: comment_state::IsSet, 2009 S::Handle: comment_state::IsSet, 2010 S::Comment: comment_state::IsSet, 2011 S::CreatedAt: comment_state::IsSet, 2012 S::Book: comment_state::IsSet, 2013 S::Parent: comment_state::IsSet, 2014{ 2015 /// Build the final struct 2016 pub fn build(self) -> Comment<'a> { 2017 Comment { 2018 book: self.__unsafe_private_named.0.unwrap(), 2019 comment: self.__unsafe_private_named.1.unwrap(), 2020 created_at: self.__unsafe_private_named.2.unwrap(), 2021 did: self.__unsafe_private_named.3.unwrap(), 2022 handle: self.__unsafe_private_named.4.unwrap(), 2023 parent: self.__unsafe_private_named.5.unwrap(), 2024 extra_data: Default::default(), 2025 } 2026 } 2027 /// Build the final struct with custom extra_data 2028 pub fn build_with_data( 2029 self, 2030 extra_data: std::collections::BTreeMap< 2031 jacquard_common::smol_str::SmolStr, 2032 jacquard_common::types::value::Data<'a>, 2033 >, 2034 ) -> Comment<'a> { 2035 Comment { 2036 book: self.__unsafe_private_named.0.unwrap(), 2037 comment: self.__unsafe_private_named.1.unwrap(), 2038 created_at: self.__unsafe_private_named.2.unwrap(), 2039 did: self.__unsafe_private_named.3.unwrap(), 2040 handle: self.__unsafe_private_named.4.unwrap(), 2041 parent: self.__unsafe_private_named.5.unwrap(), 2042 extra_data: Some(extra_data), 2043 } 2044 } 2045} 2046 2047impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Comment<'a> { 2048 fn nsid() -> &'static str { 2049 "buzz.bookhive.defs" 2050 } 2051 fn def_name() -> &'static str { 2052 "comment" 2053 } 2054 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { 2055 lexicon_doc_buzz_bookhive_defs() 2056 } 2057 fn validate( 2058 &self, 2059 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { 2060 { 2061 let value = &self.comment; 2062 #[allow(unused_comparisons)] 2063 if <str>::len(value.as_ref()) > 100000usize { 2064 return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength { 2065 path: ::jacquard_lexicon::validation::ValidationPath::from_field( 2066 "comment", 2067 ), 2068 max: 100000usize, 2069 actual: <str>::len(value.as_ref()), 2070 }); 2071 } 2072 } 2073 { 2074 let value = &self.comment; 2075 { 2076 let count = ::unicode_segmentation::UnicodeSegmentation::graphemes( 2077 value.as_ref(), 2078 true, 2079 ) 2080 .count(); 2081 if count > 10000usize { 2082 return Err(::jacquard_lexicon::validation::ConstraintError::MaxGraphemes { 2083 path: ::jacquard_lexicon::validation::ValidationPath::from_field( 2084 "comment", 2085 ), 2086 max: 10000usize, 2087 actual: count, 2088 }); 2089 } 2090 } 2091 } 2092 Ok(()) 2093 } 2094} 2095 2096/// User has finished reading the book 2097#[derive( 2098 serde::Serialize, 2099 serde::Deserialize, 2100 Debug, 2101 Clone, 2102 PartialEq, 2103 Eq, 2104 Hash, 2105 jacquard_derive::IntoStatic 2106)] 2107pub struct Finished; 2108impl std::fmt::Display for Finished { 2109 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 2110 write!(f, "finished") 2111 } 2112} 2113 2114/// User owns the book 2115#[derive( 2116 serde::Serialize, 2117 serde::Deserialize, 2118 Debug, 2119 Clone, 2120 PartialEq, 2121 Eq, 2122 Hash, 2123 jacquard_derive::IntoStatic 2124)] 2125pub struct Owned; 2126impl std::fmt::Display for Owned { 2127 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 2128 write!(f, "owned") 2129 } 2130} 2131 2132#[jacquard_derive::lexicon] 2133#[derive( 2134 serde::Serialize, 2135 serde::Deserialize, 2136 Debug, 2137 Clone, 2138 PartialEq, 2139 Eq, 2140 jacquard_derive::IntoStatic 2141)] 2142#[serde(rename_all = "camelCase")] 2143pub struct Profile<'a> { 2144 #[serde(skip_serializing_if = "std::option::Option::is_none")] 2145 #[serde(borrow)] 2146 pub avatar: std::option::Option<jacquard_common::CowStr<'a>>, 2147 pub books_read: i64, 2148 #[serde(skip_serializing_if = "std::option::Option::is_none")] 2149 #[serde(borrow)] 2150 pub description: std::option::Option<jacquard_common::CowStr<'a>>, 2151 #[serde(borrow)] 2152 pub display_name: jacquard_common::CowStr<'a>, 2153 #[serde(borrow)] 2154 pub handle: jacquard_common::CowStr<'a>, 2155 /// Whether the authed user is following this profile 2156 #[serde(skip_serializing_if = "std::option::Option::is_none")] 2157 pub is_following: std::option::Option<bool>, 2158 pub reviews: i64, 2159} 2160 2161pub mod profile_state { 2162 2163 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 2164 #[allow(unused)] 2165 use ::core::marker::PhantomData; 2166 mod sealed { 2167 pub trait Sealed {} 2168 } 2169 /// State trait tracking which required fields have been set 2170 pub trait State: sealed::Sealed { 2171 type BooksRead; 2172 type DisplayName; 2173 type Reviews; 2174 type Handle; 2175 } 2176 /// Empty state - all required fields are unset 2177 pub struct Empty(()); 2178 impl sealed::Sealed for Empty {} 2179 impl State for Empty { 2180 type BooksRead = Unset; 2181 type DisplayName = Unset; 2182 type Reviews = Unset; 2183 type Handle = Unset; 2184 } 2185 ///State transition - sets the `books_read` field to Set 2186 pub struct SetBooksRead<S: State = Empty>(PhantomData<fn() -> S>); 2187 impl<S: State> sealed::Sealed for SetBooksRead<S> {} 2188 impl<S: State> State for SetBooksRead<S> { 2189 type BooksRead = Set<members::books_read>; 2190 type DisplayName = S::DisplayName; 2191 type Reviews = S::Reviews; 2192 type Handle = S::Handle; 2193 } 2194 ///State transition - sets the `display_name` field to Set 2195 pub struct SetDisplayName<S: State = Empty>(PhantomData<fn() -> S>); 2196 impl<S: State> sealed::Sealed for SetDisplayName<S> {} 2197 impl<S: State> State for SetDisplayName<S> { 2198 type BooksRead = S::BooksRead; 2199 type DisplayName = Set<members::display_name>; 2200 type Reviews = S::Reviews; 2201 type Handle = S::Handle; 2202 } 2203 ///State transition - sets the `reviews` field to Set 2204 pub struct SetReviews<S: State = Empty>(PhantomData<fn() -> S>); 2205 impl<S: State> sealed::Sealed for SetReviews<S> {} 2206 impl<S: State> State for SetReviews<S> { 2207 type BooksRead = S::BooksRead; 2208 type DisplayName = S::DisplayName; 2209 type Reviews = Set<members::reviews>; 2210 type Handle = S::Handle; 2211 } 2212 ///State transition - sets the `handle` field to Set 2213 pub struct SetHandle<S: State = Empty>(PhantomData<fn() -> S>); 2214 impl<S: State> sealed::Sealed for SetHandle<S> {} 2215 impl<S: State> State for SetHandle<S> { 2216 type BooksRead = S::BooksRead; 2217 type DisplayName = S::DisplayName; 2218 type Reviews = S::Reviews; 2219 type Handle = Set<members::handle>; 2220 } 2221 /// Marker types for field names 2222 #[allow(non_camel_case_types)] 2223 pub mod members { 2224 ///Marker type for the `books_read` field 2225 pub struct books_read(()); 2226 ///Marker type for the `display_name` field 2227 pub struct display_name(()); 2228 ///Marker type for the `reviews` field 2229 pub struct reviews(()); 2230 ///Marker type for the `handle` field 2231 pub struct handle(()); 2232 } 2233} 2234 2235/// Builder for constructing an instance of this type 2236pub struct ProfileBuilder<'a, S: profile_state::State> { 2237 _phantom_state: ::core::marker::PhantomData<fn() -> S>, 2238 __unsafe_private_named: ( 2239 ::core::option::Option<jacquard_common::CowStr<'a>>, 2240 ::core::option::Option<i64>, 2241 ::core::option::Option<jacquard_common::CowStr<'a>>, 2242 ::core::option::Option<jacquard_common::CowStr<'a>>, 2243 ::core::option::Option<jacquard_common::CowStr<'a>>, 2244 ::core::option::Option<bool>, 2245 ::core::option::Option<i64>, 2246 ), 2247 _phantom: ::core::marker::PhantomData<&'a ()>, 2248} 2249 2250impl<'a> Profile<'a> { 2251 /// Create a new builder for this type 2252 pub fn new() -> ProfileBuilder<'a, profile_state::Empty> { 2253 ProfileBuilder::new() 2254 } 2255} 2256 2257impl<'a> ProfileBuilder<'a, profile_state::Empty> { 2258 /// Create a new builder with all fields unset 2259 pub fn new() -> Self { 2260 ProfileBuilder { 2261 _phantom_state: ::core::marker::PhantomData, 2262 __unsafe_private_named: (None, None, None, None, None, None, None), 2263 _phantom: ::core::marker::PhantomData, 2264 } 2265 } 2266} 2267 2268impl<'a, S: profile_state::State> ProfileBuilder<'a, S> { 2269 /// Set the `avatar` field (optional) 2270 pub fn avatar( 2271 mut self, 2272 value: impl Into<Option<jacquard_common::CowStr<'a>>>, 2273 ) -> Self { 2274 self.__unsafe_private_named.0 = value.into(); 2275 self 2276 } 2277 /// Set the `avatar` field to an Option value (optional) 2278 pub fn maybe_avatar(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self { 2279 self.__unsafe_private_named.0 = value; 2280 self 2281 } 2282} 2283 2284impl<'a, S> ProfileBuilder<'a, S> 2285where 2286 S: profile_state::State, 2287 S::BooksRead: profile_state::IsUnset, 2288{ 2289 /// Set the `booksRead` field (required) 2290 pub fn books_read( 2291 mut self, 2292 value: impl Into<i64>, 2293 ) -> ProfileBuilder<'a, profile_state::SetBooksRead<S>> { 2294 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); 2295 ProfileBuilder { 2296 _phantom_state: ::core::marker::PhantomData, 2297 __unsafe_private_named: self.__unsafe_private_named, 2298 _phantom: ::core::marker::PhantomData, 2299 } 2300 } 2301} 2302 2303impl<'a, S: profile_state::State> ProfileBuilder<'a, S> { 2304 /// Set the `description` field (optional) 2305 pub fn description( 2306 mut self, 2307 value: impl Into<Option<jacquard_common::CowStr<'a>>>, 2308 ) -> Self { 2309 self.__unsafe_private_named.2 = value.into(); 2310 self 2311 } 2312 /// Set the `description` field to an Option value (optional) 2313 pub fn maybe_description( 2314 mut self, 2315 value: Option<jacquard_common::CowStr<'a>>, 2316 ) -> Self { 2317 self.__unsafe_private_named.2 = value; 2318 self 2319 } 2320} 2321 2322impl<'a, S> ProfileBuilder<'a, S> 2323where 2324 S: profile_state::State, 2325 S::DisplayName: profile_state::IsUnset, 2326{ 2327 /// Set the `displayName` field (required) 2328 pub fn display_name( 2329 mut self, 2330 value: impl Into<jacquard_common::CowStr<'a>>, 2331 ) -> ProfileBuilder<'a, profile_state::SetDisplayName<S>> { 2332 self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into()); 2333 ProfileBuilder { 2334 _phantom_state: ::core::marker::PhantomData, 2335 __unsafe_private_named: self.__unsafe_private_named, 2336 _phantom: ::core::marker::PhantomData, 2337 } 2338 } 2339} 2340 2341impl<'a, S> ProfileBuilder<'a, S> 2342where 2343 S: profile_state::State, 2344 S::Handle: profile_state::IsUnset, 2345{ 2346 /// Set the `handle` field (required) 2347 pub fn handle( 2348 mut self, 2349 value: impl Into<jacquard_common::CowStr<'a>>, 2350 ) -> ProfileBuilder<'a, profile_state::SetHandle<S>> { 2351 self.__unsafe_private_named.4 = ::core::option::Option::Some(value.into()); 2352 ProfileBuilder { 2353 _phantom_state: ::core::marker::PhantomData, 2354 __unsafe_private_named: self.__unsafe_private_named, 2355 _phantom: ::core::marker::PhantomData, 2356 } 2357 } 2358} 2359 2360impl<'a, S: profile_state::State> ProfileBuilder<'a, S> { 2361 /// Set the `isFollowing` field (optional) 2362 pub fn is_following(mut self, value: impl Into<Option<bool>>) -> Self { 2363 self.__unsafe_private_named.5 = value.into(); 2364 self 2365 } 2366 /// Set the `isFollowing` field to an Option value (optional) 2367 pub fn maybe_is_following(mut self, value: Option<bool>) -> Self { 2368 self.__unsafe_private_named.5 = value; 2369 self 2370 } 2371} 2372 2373impl<'a, S> ProfileBuilder<'a, S> 2374where 2375 S: profile_state::State, 2376 S::Reviews: profile_state::IsUnset, 2377{ 2378 /// Set the `reviews` field (required) 2379 pub fn reviews( 2380 mut self, 2381 value: impl Into<i64>, 2382 ) -> ProfileBuilder<'a, profile_state::SetReviews<S>> { 2383 self.__unsafe_private_named.6 = ::core::option::Option::Some(value.into()); 2384 ProfileBuilder { 2385 _phantom_state: ::core::marker::PhantomData, 2386 __unsafe_private_named: self.__unsafe_private_named, 2387 _phantom: ::core::marker::PhantomData, 2388 } 2389 } 2390} 2391 2392impl<'a, S> ProfileBuilder<'a, S> 2393where 2394 S: profile_state::State, 2395 S::BooksRead: profile_state::IsSet, 2396 S::DisplayName: profile_state::IsSet, 2397 S::Reviews: profile_state::IsSet, 2398 S::Handle: profile_state::IsSet, 2399{ 2400 /// Build the final struct 2401 pub fn build(self) -> Profile<'a> { 2402 Profile { 2403 avatar: self.__unsafe_private_named.0, 2404 books_read: self.__unsafe_private_named.1.unwrap(), 2405 description: self.__unsafe_private_named.2, 2406 display_name: self.__unsafe_private_named.3.unwrap(), 2407 handle: self.__unsafe_private_named.4.unwrap(), 2408 is_following: self.__unsafe_private_named.5, 2409 reviews: self.__unsafe_private_named.6.unwrap(), 2410 extra_data: Default::default(), 2411 } 2412 } 2413 /// Build the final struct with custom extra_data 2414 pub fn build_with_data( 2415 self, 2416 extra_data: std::collections::BTreeMap< 2417 jacquard_common::smol_str::SmolStr, 2418 jacquard_common::types::value::Data<'a>, 2419 >, 2420 ) -> Profile<'a> { 2421 Profile { 2422 avatar: self.__unsafe_private_named.0, 2423 books_read: self.__unsafe_private_named.1.unwrap(), 2424 description: self.__unsafe_private_named.2, 2425 display_name: self.__unsafe_private_named.3.unwrap(), 2426 handle: self.__unsafe_private_named.4.unwrap(), 2427 is_following: self.__unsafe_private_named.5, 2428 reviews: self.__unsafe_private_named.6.unwrap(), 2429 extra_data: Some(extra_data), 2430 } 2431 } 2432} 2433 2434impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Profile<'a> { 2435 fn nsid() -> &'static str { 2436 "buzz.bookhive.defs" 2437 } 2438 fn def_name() -> &'static str { 2439 "profile" 2440 } 2441 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { 2442 lexicon_doc_buzz_bookhive_defs() 2443 } 2444 fn validate( 2445 &self, 2446 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { 2447 { 2448 let value = &self.books_read; 2449 if *value < 0i64 { 2450 return Err(::jacquard_lexicon::validation::ConstraintError::Minimum { 2451 path: ::jacquard_lexicon::validation::ValidationPath::from_field( 2452 "books_read", 2453 ), 2454 min: 0i64, 2455 actual: *value, 2456 }); 2457 } 2458 } 2459 { 2460 let value = &self.reviews; 2461 if *value < 0i64 { 2462 return Err(::jacquard_lexicon::validation::ConstraintError::Minimum { 2463 path: ::jacquard_lexicon::validation::ValidationPath::from_field( 2464 "reviews", 2465 ), 2466 min: 0i64, 2467 actual: *value, 2468 }); 2469 } 2470 } 2471 Ok(()) 2472 } 2473} 2474 2475/// User is currently reading the book 2476#[derive( 2477 serde::Serialize, 2478 serde::Deserialize, 2479 Debug, 2480 Clone, 2481 PartialEq, 2482 Eq, 2483 Hash, 2484 jacquard_derive::IntoStatic 2485)] 2486pub struct Reading; 2487impl std::fmt::Display for Reading { 2488 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 2489 write!(f, "reading") 2490 } 2491} 2492 2493#[jacquard_derive::lexicon] 2494#[derive( 2495 serde::Serialize, 2496 serde::Deserialize, 2497 Debug, 2498 Clone, 2499 PartialEq, 2500 Eq, 2501 jacquard_derive::IntoStatic 2502)] 2503#[serde(rename_all = "camelCase")] 2504pub struct Review<'a> { 2505 /// The date the review was created 2506 pub created_at: jacquard_common::types::string::Datetime, 2507 /// The DID of the user who made the review 2508 #[serde(borrow)] 2509 pub did: jacquard_common::CowStr<'a>, 2510 /// The handle of the user who made the review 2511 #[serde(borrow)] 2512 pub handle: jacquard_common::CowStr<'a>, 2513 /// The review content 2514 #[serde(borrow)] 2515 pub review: jacquard_common::CowStr<'a>, 2516 /// The number of stars given to the book 2517 #[serde(skip_serializing_if = "std::option::Option::is_none")] 2518 pub stars: std::option::Option<i64>, 2519} 2520 2521pub mod review_state { 2522 2523 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 2524 #[allow(unused)] 2525 use ::core::marker::PhantomData; 2526 mod sealed { 2527 pub trait Sealed {} 2528 } 2529 /// State trait tracking which required fields have been set 2530 pub trait State: sealed::Sealed { 2531 type Handle; 2532 type Did; 2533 type CreatedAt; 2534 type Review; 2535 } 2536 /// Empty state - all required fields are unset 2537 pub struct Empty(()); 2538 impl sealed::Sealed for Empty {} 2539 impl State for Empty { 2540 type Handle = Unset; 2541 type Did = Unset; 2542 type CreatedAt = Unset; 2543 type Review = Unset; 2544 } 2545 ///State transition - sets the `handle` field to Set 2546 pub struct SetHandle<S: State = Empty>(PhantomData<fn() -> S>); 2547 impl<S: State> sealed::Sealed for SetHandle<S> {} 2548 impl<S: State> State for SetHandle<S> { 2549 type Handle = Set<members::handle>; 2550 type Did = S::Did; 2551 type CreatedAt = S::CreatedAt; 2552 type Review = S::Review; 2553 } 2554 ///State transition - sets the `did` field to Set 2555 pub struct SetDid<S: State = Empty>(PhantomData<fn() -> S>); 2556 impl<S: State> sealed::Sealed for SetDid<S> {} 2557 impl<S: State> State for SetDid<S> { 2558 type Handle = S::Handle; 2559 type Did = Set<members::did>; 2560 type CreatedAt = S::CreatedAt; 2561 type Review = S::Review; 2562 } 2563 ///State transition - sets the `created_at` field to Set 2564 pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>); 2565 impl<S: State> sealed::Sealed for SetCreatedAt<S> {} 2566 impl<S: State> State for SetCreatedAt<S> { 2567 type Handle = S::Handle; 2568 type Did = S::Did; 2569 type CreatedAt = Set<members::created_at>; 2570 type Review = S::Review; 2571 } 2572 ///State transition - sets the `review` field to Set 2573 pub struct SetReview<S: State = Empty>(PhantomData<fn() -> S>); 2574 impl<S: State> sealed::Sealed for SetReview<S> {} 2575 impl<S: State> State for SetReview<S> { 2576 type Handle = S::Handle; 2577 type Did = S::Did; 2578 type CreatedAt = S::CreatedAt; 2579 type Review = Set<members::review>; 2580 } 2581 /// Marker types for field names 2582 #[allow(non_camel_case_types)] 2583 pub mod members { 2584 ///Marker type for the `handle` field 2585 pub struct handle(()); 2586 ///Marker type for the `did` field 2587 pub struct did(()); 2588 ///Marker type for the `created_at` field 2589 pub struct created_at(()); 2590 ///Marker type for the `review` field 2591 pub struct review(()); 2592 } 2593} 2594 2595/// Builder for constructing an instance of this type 2596pub struct ReviewBuilder<'a, S: review_state::State> { 2597 _phantom_state: ::core::marker::PhantomData<fn() -> S>, 2598 __unsafe_private_named: ( 2599 ::core::option::Option<jacquard_common::types::string::Datetime>, 2600 ::core::option::Option<jacquard_common::CowStr<'a>>, 2601 ::core::option::Option<jacquard_common::CowStr<'a>>, 2602 ::core::option::Option<jacquard_common::CowStr<'a>>, 2603 ::core::option::Option<i64>, 2604 ), 2605 _phantom: ::core::marker::PhantomData<&'a ()>, 2606} 2607 2608impl<'a> Review<'a> { 2609 /// Create a new builder for this type 2610 pub fn new() -> ReviewBuilder<'a, review_state::Empty> { 2611 ReviewBuilder::new() 2612 } 2613} 2614 2615impl<'a> ReviewBuilder<'a, review_state::Empty> { 2616 /// Create a new builder with all fields unset 2617 pub fn new() -> Self { 2618 ReviewBuilder { 2619 _phantom_state: ::core::marker::PhantomData, 2620 __unsafe_private_named: (None, None, None, None, None), 2621 _phantom: ::core::marker::PhantomData, 2622 } 2623 } 2624} 2625 2626impl<'a, S> ReviewBuilder<'a, S> 2627where 2628 S: review_state::State, 2629 S::CreatedAt: review_state::IsUnset, 2630{ 2631 /// Set the `createdAt` field (required) 2632 pub fn created_at( 2633 mut self, 2634 value: impl Into<jacquard_common::types::string::Datetime>, 2635 ) -> ReviewBuilder<'a, review_state::SetCreatedAt<S>> { 2636 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); 2637 ReviewBuilder { 2638 _phantom_state: ::core::marker::PhantomData, 2639 __unsafe_private_named: self.__unsafe_private_named, 2640 _phantom: ::core::marker::PhantomData, 2641 } 2642 } 2643} 2644 2645impl<'a, S> ReviewBuilder<'a, S> 2646where 2647 S: review_state::State, 2648 S::Did: review_state::IsUnset, 2649{ 2650 /// Set the `did` field (required) 2651 pub fn did( 2652 mut self, 2653 value: impl Into<jacquard_common::CowStr<'a>>, 2654 ) -> ReviewBuilder<'a, review_state::SetDid<S>> { 2655 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); 2656 ReviewBuilder { 2657 _phantom_state: ::core::marker::PhantomData, 2658 __unsafe_private_named: self.__unsafe_private_named, 2659 _phantom: ::core::marker::PhantomData, 2660 } 2661 } 2662} 2663 2664impl<'a, S> ReviewBuilder<'a, S> 2665where 2666 S: review_state::State, 2667 S::Handle: review_state::IsUnset, 2668{ 2669 /// Set the `handle` field (required) 2670 pub fn handle( 2671 mut self, 2672 value: impl Into<jacquard_common::CowStr<'a>>, 2673 ) -> ReviewBuilder<'a, review_state::SetHandle<S>> { 2674 self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into()); 2675 ReviewBuilder { 2676 _phantom_state: ::core::marker::PhantomData, 2677 __unsafe_private_named: self.__unsafe_private_named, 2678 _phantom: ::core::marker::PhantomData, 2679 } 2680 } 2681} 2682 2683impl<'a, S> ReviewBuilder<'a, S> 2684where 2685 S: review_state::State, 2686 S::Review: review_state::IsUnset, 2687{ 2688 /// Set the `review` field (required) 2689 pub fn review( 2690 mut self, 2691 value: impl Into<jacquard_common::CowStr<'a>>, 2692 ) -> ReviewBuilder<'a, review_state::SetReview<S>> { 2693 self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into()); 2694 ReviewBuilder { 2695 _phantom_state: ::core::marker::PhantomData, 2696 __unsafe_private_named: self.__unsafe_private_named, 2697 _phantom: ::core::marker::PhantomData, 2698 } 2699 } 2700} 2701 2702impl<'a, S: review_state::State> ReviewBuilder<'a, S> { 2703 /// Set the `stars` field (optional) 2704 pub fn stars(mut self, value: impl Into<Option<i64>>) -> Self { 2705 self.__unsafe_private_named.4 = value.into(); 2706 self 2707 } 2708 /// Set the `stars` field to an Option value (optional) 2709 pub fn maybe_stars(mut self, value: Option<i64>) -> Self { 2710 self.__unsafe_private_named.4 = value; 2711 self 2712 } 2713} 2714 2715impl<'a, S> ReviewBuilder<'a, S> 2716where 2717 S: review_state::State, 2718 S::Handle: review_state::IsSet, 2719 S::Did: review_state::IsSet, 2720 S::CreatedAt: review_state::IsSet, 2721 S::Review: review_state::IsSet, 2722{ 2723 /// Build the final struct 2724 pub fn build(self) -> Review<'a> { 2725 Review { 2726 created_at: self.__unsafe_private_named.0.unwrap(), 2727 did: self.__unsafe_private_named.1.unwrap(), 2728 handle: self.__unsafe_private_named.2.unwrap(), 2729 review: self.__unsafe_private_named.3.unwrap(), 2730 stars: self.__unsafe_private_named.4, 2731 extra_data: Default::default(), 2732 } 2733 } 2734 /// Build the final struct with custom extra_data 2735 pub fn build_with_data( 2736 self, 2737 extra_data: std::collections::BTreeMap< 2738 jacquard_common::smol_str::SmolStr, 2739 jacquard_common::types::value::Data<'a>, 2740 >, 2741 ) -> Review<'a> { 2742 Review { 2743 created_at: self.__unsafe_private_named.0.unwrap(), 2744 did: self.__unsafe_private_named.1.unwrap(), 2745 handle: self.__unsafe_private_named.2.unwrap(), 2746 review: self.__unsafe_private_named.3.unwrap(), 2747 stars: self.__unsafe_private_named.4, 2748 extra_data: Some(extra_data), 2749 } 2750 } 2751} 2752 2753impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Review<'a> { 2754 fn nsid() -> &'static str { 2755 "buzz.bookhive.defs" 2756 } 2757 fn def_name() -> &'static str { 2758 "review" 2759 } 2760 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { 2761 lexicon_doc_buzz_bookhive_defs() 2762 } 2763 fn validate( 2764 &self, 2765 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { 2766 Ok(()) 2767 } 2768} 2769 2770#[jacquard_derive::lexicon] 2771#[derive( 2772 serde::Serialize, 2773 serde::Deserialize, 2774 Debug, 2775 Clone, 2776 PartialEq, 2777 Eq, 2778 jacquard_derive::IntoStatic 2779)] 2780#[serde(rename_all = "camelCase")] 2781pub struct UserBook<'a> { 2782 /// The authors of the book (tab separated) 2783 #[serde(borrow)] 2784 pub authors: jacquard_common::CowStr<'a>, 2785 /// Progress tracking information for the book 2786 #[serde(skip_serializing_if = "std::option::Option::is_none")] 2787 #[serde(borrow)] 2788 pub book_progress: std::option::Option<crate::buzz_bookhive::BookProgress<'a>>, 2789 /// Cover image of the book 2790 #[serde(skip_serializing_if = "std::option::Option::is_none")] 2791 #[serde(borrow)] 2792 pub cover: std::option::Option<jacquard_common::CowStr<'a>>, 2793 pub created_at: jacquard_common::types::string::Datetime, 2794 /// Book description/summary 2795 #[serde(skip_serializing_if = "std::option::Option::is_none")] 2796 #[serde(borrow)] 2797 pub description: std::option::Option<jacquard_common::CowStr<'a>>, 2798 /// The date the user finished reading the book 2799 #[serde(skip_serializing_if = "std::option::Option::is_none")] 2800 pub finished_at: std::option::Option<jacquard_common::types::string::Datetime>, 2801 /// The book's hive id, used to correlate user's books with the hive 2802 #[serde(borrow)] 2803 pub hive_id: jacquard_common::CowStr<'a>, 2804 /// Average rating (0-1000) 2805 #[serde(skip_serializing_if = "std::option::Option::is_none")] 2806 pub rating: std::option::Option<i64>, 2807 /// The book's review 2808 #[serde(skip_serializing_if = "std::option::Option::is_none")] 2809 #[serde(borrow)] 2810 pub review: std::option::Option<jacquard_common::CowStr<'a>>, 2811 /// Number of stars given to the book (1-10) which will be mapped to 1-5 stars 2812 #[serde(skip_serializing_if = "std::option::Option::is_none")] 2813 pub stars: std::option::Option<i64>, 2814 /// The date the user started reading the book 2815 #[serde(skip_serializing_if = "std::option::Option::is_none")] 2816 pub started_at: std::option::Option<jacquard_common::types::string::Datetime>, 2817 #[serde(skip_serializing_if = "std::option::Option::is_none")] 2818 #[serde(borrow)] 2819 pub status: std::option::Option<UserBookStatus<'a>>, 2820 /// Cover image of the book 2821 #[serde(borrow)] 2822 pub thumbnail: jacquard_common::CowStr<'a>, 2823 /// The title of the book 2824 #[serde(borrow)] 2825 pub title: jacquard_common::CowStr<'a>, 2826 /// The DID of the user who added the book 2827 #[serde(borrow)] 2828 pub user_did: jacquard_common::CowStr<'a>, 2829 /// The handle of the user who added the book 2830 #[serde(skip_serializing_if = "std::option::Option::is_none")] 2831 #[serde(borrow)] 2832 pub user_handle: std::option::Option<jacquard_common::CowStr<'a>>, 2833} 2834 2835pub mod user_book_state { 2836 2837 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 2838 #[allow(unused)] 2839 use ::core::marker::PhantomData; 2840 mod sealed { 2841 pub trait Sealed {} 2842 } 2843 /// State trait tracking which required fields have been set 2844 pub trait State: sealed::Sealed { 2845 type HiveId; 2846 type Thumbnail; 2847 type UserDid; 2848 type Title; 2849 type Authors; 2850 type CreatedAt; 2851 } 2852 /// Empty state - all required fields are unset 2853 pub struct Empty(()); 2854 impl sealed::Sealed for Empty {} 2855 impl State for Empty { 2856 type HiveId = Unset; 2857 type Thumbnail = Unset; 2858 type UserDid = Unset; 2859 type Title = Unset; 2860 type Authors = Unset; 2861 type CreatedAt = Unset; 2862 } 2863 ///State transition - sets the `hive_id` field to Set 2864 pub struct SetHiveId<S: State = Empty>(PhantomData<fn() -> S>); 2865 impl<S: State> sealed::Sealed for SetHiveId<S> {} 2866 impl<S: State> State for SetHiveId<S> { 2867 type HiveId = Set<members::hive_id>; 2868 type Thumbnail = S::Thumbnail; 2869 type UserDid = S::UserDid; 2870 type Title = S::Title; 2871 type Authors = S::Authors; 2872 type CreatedAt = S::CreatedAt; 2873 } 2874 ///State transition - sets the `thumbnail` field to Set 2875 pub struct SetThumbnail<S: State = Empty>(PhantomData<fn() -> S>); 2876 impl<S: State> sealed::Sealed for SetThumbnail<S> {} 2877 impl<S: State> State for SetThumbnail<S> { 2878 type HiveId = S::HiveId; 2879 type Thumbnail = Set<members::thumbnail>; 2880 type UserDid = S::UserDid; 2881 type Title = S::Title; 2882 type Authors = S::Authors; 2883 type CreatedAt = S::CreatedAt; 2884 } 2885 ///State transition - sets the `user_did` field to Set 2886 pub struct SetUserDid<S: State = Empty>(PhantomData<fn() -> S>); 2887 impl<S: State> sealed::Sealed for SetUserDid<S> {} 2888 impl<S: State> State for SetUserDid<S> { 2889 type HiveId = S::HiveId; 2890 type Thumbnail = S::Thumbnail; 2891 type UserDid = Set<members::user_did>; 2892 type Title = S::Title; 2893 type Authors = S::Authors; 2894 type CreatedAt = S::CreatedAt; 2895 } 2896 ///State transition - sets the `title` field to Set 2897 pub struct SetTitle<S: State = Empty>(PhantomData<fn() -> S>); 2898 impl<S: State> sealed::Sealed for SetTitle<S> {} 2899 impl<S: State> State for SetTitle<S> { 2900 type HiveId = S::HiveId; 2901 type Thumbnail = S::Thumbnail; 2902 type UserDid = S::UserDid; 2903 type Title = Set<members::title>; 2904 type Authors = S::Authors; 2905 type CreatedAt = S::CreatedAt; 2906 } 2907 ///State transition - sets the `authors` field to Set 2908 pub struct SetAuthors<S: State = Empty>(PhantomData<fn() -> S>); 2909 impl<S: State> sealed::Sealed for SetAuthors<S> {} 2910 impl<S: State> State for SetAuthors<S> { 2911 type HiveId = S::HiveId; 2912 type Thumbnail = S::Thumbnail; 2913 type UserDid = S::UserDid; 2914 type Title = S::Title; 2915 type Authors = Set<members::authors>; 2916 type CreatedAt = S::CreatedAt; 2917 } 2918 ///State transition - sets the `created_at` field to Set 2919 pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>); 2920 impl<S: State> sealed::Sealed for SetCreatedAt<S> {} 2921 impl<S: State> State for SetCreatedAt<S> { 2922 type HiveId = S::HiveId; 2923 type Thumbnail = S::Thumbnail; 2924 type UserDid = S::UserDid; 2925 type Title = S::Title; 2926 type Authors = S::Authors; 2927 type CreatedAt = Set<members::created_at>; 2928 } 2929 /// Marker types for field names 2930 #[allow(non_camel_case_types)] 2931 pub mod members { 2932 ///Marker type for the `hive_id` field 2933 pub struct hive_id(()); 2934 ///Marker type for the `thumbnail` field 2935 pub struct thumbnail(()); 2936 ///Marker type for the `user_did` field 2937 pub struct user_did(()); 2938 ///Marker type for the `title` field 2939 pub struct title(()); 2940 ///Marker type for the `authors` field 2941 pub struct authors(()); 2942 ///Marker type for the `created_at` field 2943 pub struct created_at(()); 2944 } 2945} 2946 2947/// Builder for constructing an instance of this type 2948pub struct UserBookBuilder<'a, S: user_book_state::State> { 2949 _phantom_state: ::core::marker::PhantomData<fn() -> S>, 2950 __unsafe_private_named: ( 2951 ::core::option::Option<jacquard_common::CowStr<'a>>, 2952 ::core::option::Option<crate::buzz_bookhive::BookProgress<'a>>, 2953 ::core::option::Option<jacquard_common::CowStr<'a>>, 2954 ::core::option::Option<jacquard_common::types::string::Datetime>, 2955 ::core::option::Option<jacquard_common::CowStr<'a>>, 2956 ::core::option::Option<jacquard_common::types::string::Datetime>, 2957 ::core::option::Option<jacquard_common::CowStr<'a>>, 2958 ::core::option::Option<i64>, 2959 ::core::option::Option<jacquard_common::CowStr<'a>>, 2960 ::core::option::Option<i64>, 2961 ::core::option::Option<jacquard_common::types::string::Datetime>, 2962 ::core::option::Option<UserBookStatus<'a>>, 2963 ::core::option::Option<jacquard_common::CowStr<'a>>, 2964 ::core::option::Option<jacquard_common::CowStr<'a>>, 2965 ::core::option::Option<jacquard_common::CowStr<'a>>, 2966 ::core::option::Option<jacquard_common::CowStr<'a>>, 2967 ), 2968 _phantom: ::core::marker::PhantomData<&'a ()>, 2969} 2970 2971impl<'a> UserBook<'a> { 2972 /// Create a new builder for this type 2973 pub fn new() -> UserBookBuilder<'a, user_book_state::Empty> { 2974 UserBookBuilder::new() 2975 } 2976} 2977 2978impl<'a> UserBookBuilder<'a, user_book_state::Empty> { 2979 /// Create a new builder with all fields unset 2980 pub fn new() -> Self { 2981 UserBookBuilder { 2982 _phantom_state: ::core::marker::PhantomData, 2983 __unsafe_private_named: ( 2984 None, 2985 None, 2986 None, 2987 None, 2988 None, 2989 None, 2990 None, 2991 None, 2992 None, 2993 None, 2994 None, 2995 None, 2996 None, 2997 None, 2998 None, 2999 None, 3000 ), 3001 _phantom: ::core::marker::PhantomData, 3002 } 3003 } 3004} 3005 3006impl<'a, S> UserBookBuilder<'a, S> 3007where 3008 S: user_book_state::State, 3009 S::Authors: user_book_state::IsUnset, 3010{ 3011 /// Set the `authors` field (required) 3012 pub fn authors( 3013 mut self, 3014 value: impl Into<jacquard_common::CowStr<'a>>, 3015 ) -> UserBookBuilder<'a, user_book_state::SetAuthors<S>> { 3016 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); 3017 UserBookBuilder { 3018 _phantom_state: ::core::marker::PhantomData, 3019 __unsafe_private_named: self.__unsafe_private_named, 3020 _phantom: ::core::marker::PhantomData, 3021 } 3022 } 3023} 3024 3025impl<'a, S: user_book_state::State> UserBookBuilder<'a, S> { 3026 /// Set the `bookProgress` field (optional) 3027 pub fn book_progress( 3028 mut self, 3029 value: impl Into<Option<crate::buzz_bookhive::BookProgress<'a>>>, 3030 ) -> Self { 3031 self.__unsafe_private_named.1 = value.into(); 3032 self 3033 } 3034 /// Set the `bookProgress` field to an Option value (optional) 3035 pub fn maybe_book_progress( 3036 mut self, 3037 value: Option<crate::buzz_bookhive::BookProgress<'a>>, 3038 ) -> Self { 3039 self.__unsafe_private_named.1 = value; 3040 self 3041 } 3042} 3043 3044impl<'a, S: user_book_state::State> UserBookBuilder<'a, S> { 3045 /// Set the `cover` field (optional) 3046 pub fn cover( 3047 mut self, 3048 value: impl Into<Option<jacquard_common::CowStr<'a>>>, 3049 ) -> Self { 3050 self.__unsafe_private_named.2 = value.into(); 3051 self 3052 } 3053 /// Set the `cover` field to an Option value (optional) 3054 pub fn maybe_cover(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self { 3055 self.__unsafe_private_named.2 = value; 3056 self 3057 } 3058} 3059 3060impl<'a, S> UserBookBuilder<'a, S> 3061where 3062 S: user_book_state::State, 3063 S::CreatedAt: user_book_state::IsUnset, 3064{ 3065 /// Set the `createdAt` field (required) 3066 pub fn created_at( 3067 mut self, 3068 value: impl Into<jacquard_common::types::string::Datetime>, 3069 ) -> UserBookBuilder<'a, user_book_state::SetCreatedAt<S>> { 3070 self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into()); 3071 UserBookBuilder { 3072 _phantom_state: ::core::marker::PhantomData, 3073 __unsafe_private_named: self.__unsafe_private_named, 3074 _phantom: ::core::marker::PhantomData, 3075 } 3076 } 3077} 3078 3079impl<'a, S: user_book_state::State> UserBookBuilder<'a, S> { 3080 /// Set the `description` field (optional) 3081 pub fn description( 3082 mut self, 3083 value: impl Into<Option<jacquard_common::CowStr<'a>>>, 3084 ) -> Self { 3085 self.__unsafe_private_named.4 = value.into(); 3086 self 3087 } 3088 /// Set the `description` field to an Option value (optional) 3089 pub fn maybe_description( 3090 mut self, 3091 value: Option<jacquard_common::CowStr<'a>>, 3092 ) -> Self { 3093 self.__unsafe_private_named.4 = value; 3094 self 3095 } 3096} 3097 3098impl<'a, S: user_book_state::State> UserBookBuilder<'a, S> { 3099 /// Set the `finishedAt` field (optional) 3100 pub fn finished_at( 3101 mut self, 3102 value: impl Into<Option<jacquard_common::types::string::Datetime>>, 3103 ) -> Self { 3104 self.__unsafe_private_named.5 = value.into(); 3105 self 3106 } 3107 /// Set the `finishedAt` field to an Option value (optional) 3108 pub fn maybe_finished_at( 3109 mut self, 3110 value: Option<jacquard_common::types::string::Datetime>, 3111 ) -> Self { 3112 self.__unsafe_private_named.5 = value; 3113 self 3114 } 3115} 3116 3117impl<'a, S> UserBookBuilder<'a, S> 3118where 3119 S: user_book_state::State, 3120 S::HiveId: user_book_state::IsUnset, 3121{ 3122 /// Set the `hiveId` field (required) 3123 pub fn hive_id( 3124 mut self, 3125 value: impl Into<jacquard_common::CowStr<'a>>, 3126 ) -> UserBookBuilder<'a, user_book_state::SetHiveId<S>> { 3127 self.__unsafe_private_named.6 = ::core::option::Option::Some(value.into()); 3128 UserBookBuilder { 3129 _phantom_state: ::core::marker::PhantomData, 3130 __unsafe_private_named: self.__unsafe_private_named, 3131 _phantom: ::core::marker::PhantomData, 3132 } 3133 } 3134} 3135 3136impl<'a, S: user_book_state::State> UserBookBuilder<'a, S> { 3137 /// Set the `rating` field (optional) 3138 pub fn rating(mut self, value: impl Into<Option<i64>>) -> Self { 3139 self.__unsafe_private_named.7 = value.into(); 3140 self 3141 } 3142 /// Set the `rating` field to an Option value (optional) 3143 pub fn maybe_rating(mut self, value: Option<i64>) -> Self { 3144 self.__unsafe_private_named.7 = value; 3145 self 3146 } 3147} 3148 3149impl<'a, S: user_book_state::State> UserBookBuilder<'a, S> { 3150 /// Set the `review` field (optional) 3151 pub fn review( 3152 mut self, 3153 value: impl Into<Option<jacquard_common::CowStr<'a>>>, 3154 ) -> Self { 3155 self.__unsafe_private_named.8 = value.into(); 3156 self 3157 } 3158 /// Set the `review` field to an Option value (optional) 3159 pub fn maybe_review(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self { 3160 self.__unsafe_private_named.8 = value; 3161 self 3162 } 3163} 3164 3165impl<'a, S: user_book_state::State> UserBookBuilder<'a, S> { 3166 /// Set the `stars` field (optional) 3167 pub fn stars(mut self, value: impl Into<Option<i64>>) -> Self { 3168 self.__unsafe_private_named.9 = value.into(); 3169 self 3170 } 3171 /// Set the `stars` field to an Option value (optional) 3172 pub fn maybe_stars(mut self, value: Option<i64>) -> Self { 3173 self.__unsafe_private_named.9 = value; 3174 self 3175 } 3176} 3177 3178impl<'a, S: user_book_state::State> UserBookBuilder<'a, S> { 3179 /// Set the `startedAt` field (optional) 3180 pub fn started_at( 3181 mut self, 3182 value: impl Into<Option<jacquard_common::types::string::Datetime>>, 3183 ) -> Self { 3184 self.__unsafe_private_named.10 = value.into(); 3185 self 3186 } 3187 /// Set the `startedAt` field to an Option value (optional) 3188 pub fn maybe_started_at( 3189 mut self, 3190 value: Option<jacquard_common::types::string::Datetime>, 3191 ) -> Self { 3192 self.__unsafe_private_named.10 = value; 3193 self 3194 } 3195} 3196 3197impl<'a, S: user_book_state::State> UserBookBuilder<'a, S> { 3198 /// Set the `status` field (optional) 3199 pub fn status(mut self, value: impl Into<Option<UserBookStatus<'a>>>) -> Self { 3200 self.__unsafe_private_named.11 = value.into(); 3201 self 3202 } 3203 /// Set the `status` field to an Option value (optional) 3204 pub fn maybe_status(mut self, value: Option<UserBookStatus<'a>>) -> Self { 3205 self.__unsafe_private_named.11 = value; 3206 self 3207 } 3208} 3209 3210impl<'a, S> UserBookBuilder<'a, S> 3211where 3212 S: user_book_state::State, 3213 S::Thumbnail: user_book_state::IsUnset, 3214{ 3215 /// Set the `thumbnail` field (required) 3216 pub fn thumbnail( 3217 mut self, 3218 value: impl Into<jacquard_common::CowStr<'a>>, 3219 ) -> UserBookBuilder<'a, user_book_state::SetThumbnail<S>> { 3220 self.__unsafe_private_named.12 = ::core::option::Option::Some(value.into()); 3221 UserBookBuilder { 3222 _phantom_state: ::core::marker::PhantomData, 3223 __unsafe_private_named: self.__unsafe_private_named, 3224 _phantom: ::core::marker::PhantomData, 3225 } 3226 } 3227} 3228 3229impl<'a, S> UserBookBuilder<'a, S> 3230where 3231 S: user_book_state::State, 3232 S::Title: user_book_state::IsUnset, 3233{ 3234 /// Set the `title` field (required) 3235 pub fn title( 3236 mut self, 3237 value: impl Into<jacquard_common::CowStr<'a>>, 3238 ) -> UserBookBuilder<'a, user_book_state::SetTitle<S>> { 3239 self.__unsafe_private_named.13 = ::core::option::Option::Some(value.into()); 3240 UserBookBuilder { 3241 _phantom_state: ::core::marker::PhantomData, 3242 __unsafe_private_named: self.__unsafe_private_named, 3243 _phantom: ::core::marker::PhantomData, 3244 } 3245 } 3246} 3247 3248impl<'a, S> UserBookBuilder<'a, S> 3249where 3250 S: user_book_state::State, 3251 S::UserDid: user_book_state::IsUnset, 3252{ 3253 /// Set the `userDid` field (required) 3254 pub fn user_did( 3255 mut self, 3256 value: impl Into<jacquard_common::CowStr<'a>>, 3257 ) -> UserBookBuilder<'a, user_book_state::SetUserDid<S>> { 3258 self.__unsafe_private_named.14 = ::core::option::Option::Some(value.into()); 3259 UserBookBuilder { 3260 _phantom_state: ::core::marker::PhantomData, 3261 __unsafe_private_named: self.__unsafe_private_named, 3262 _phantom: ::core::marker::PhantomData, 3263 } 3264 } 3265} 3266 3267impl<'a, S: user_book_state::State> UserBookBuilder<'a, S> { 3268 /// Set the `userHandle` field (optional) 3269 pub fn user_handle( 3270 mut self, 3271 value: impl Into<Option<jacquard_common::CowStr<'a>>>, 3272 ) -> Self { 3273 self.__unsafe_private_named.15 = value.into(); 3274 self 3275 } 3276 /// Set the `userHandle` field to an Option value (optional) 3277 pub fn maybe_user_handle( 3278 mut self, 3279 value: Option<jacquard_common::CowStr<'a>>, 3280 ) -> Self { 3281 self.__unsafe_private_named.15 = value; 3282 self 3283 } 3284} 3285 3286impl<'a, S> UserBookBuilder<'a, S> 3287where 3288 S: user_book_state::State, 3289 S::HiveId: user_book_state::IsSet, 3290 S::Thumbnail: user_book_state::IsSet, 3291 S::UserDid: user_book_state::IsSet, 3292 S::Title: user_book_state::IsSet, 3293 S::Authors: user_book_state::IsSet, 3294 S::CreatedAt: user_book_state::IsSet, 3295{ 3296 /// Build the final struct 3297 pub fn build(self) -> UserBook<'a> { 3298 UserBook { 3299 authors: self.__unsafe_private_named.0.unwrap(), 3300 book_progress: self.__unsafe_private_named.1, 3301 cover: self.__unsafe_private_named.2, 3302 created_at: self.__unsafe_private_named.3.unwrap(), 3303 description: self.__unsafe_private_named.4, 3304 finished_at: self.__unsafe_private_named.5, 3305 hive_id: self.__unsafe_private_named.6.unwrap(), 3306 rating: self.__unsafe_private_named.7, 3307 review: self.__unsafe_private_named.8, 3308 stars: self.__unsafe_private_named.9, 3309 started_at: self.__unsafe_private_named.10, 3310 status: self.__unsafe_private_named.11, 3311 thumbnail: self.__unsafe_private_named.12.unwrap(), 3312 title: self.__unsafe_private_named.13.unwrap(), 3313 user_did: self.__unsafe_private_named.14.unwrap(), 3314 user_handle: self.__unsafe_private_named.15, 3315 extra_data: Default::default(), 3316 } 3317 } 3318 /// Build the final struct with custom extra_data 3319 pub fn build_with_data( 3320 self, 3321 extra_data: std::collections::BTreeMap< 3322 jacquard_common::smol_str::SmolStr, 3323 jacquard_common::types::value::Data<'a>, 3324 >, 3325 ) -> UserBook<'a> { 3326 UserBook { 3327 authors: self.__unsafe_private_named.0.unwrap(), 3328 book_progress: self.__unsafe_private_named.1, 3329 cover: self.__unsafe_private_named.2, 3330 created_at: self.__unsafe_private_named.3.unwrap(), 3331 description: self.__unsafe_private_named.4, 3332 finished_at: self.__unsafe_private_named.5, 3333 hive_id: self.__unsafe_private_named.6.unwrap(), 3334 rating: self.__unsafe_private_named.7, 3335 review: self.__unsafe_private_named.8, 3336 stars: self.__unsafe_private_named.9, 3337 started_at: self.__unsafe_private_named.10, 3338 status: self.__unsafe_private_named.11, 3339 thumbnail: self.__unsafe_private_named.12.unwrap(), 3340 title: self.__unsafe_private_named.13.unwrap(), 3341 user_did: self.__unsafe_private_named.14.unwrap(), 3342 user_handle: self.__unsafe_private_named.15, 3343 extra_data: Some(extra_data), 3344 } 3345 } 3346} 3347 3348#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3349pub enum UserBookStatus<'a> { 3350 Finished, 3351 Reading, 3352 WantToRead, 3353 Abandoned, 3354 Owned, 3355 Other(jacquard_common::CowStr<'a>), 3356} 3357 3358impl<'a> UserBookStatus<'a> { 3359 pub fn as_str(&self) -> &str { 3360 match self { 3361 Self::Finished => "buzz.bookhive.defs#finished", 3362 Self::Reading => "buzz.bookhive.defs#reading", 3363 Self::WantToRead => "buzz.bookhive.defs#wantToRead", 3364 Self::Abandoned => "buzz.bookhive.defs#abandoned", 3365 Self::Owned => "buzz.bookhive.defs#owned", 3366 Self::Other(s) => s.as_ref(), 3367 } 3368 } 3369} 3370 3371impl<'a> From<&'a str> for UserBookStatus<'a> { 3372 fn from(s: &'a str) -> Self { 3373 match s { 3374 "buzz.bookhive.defs#finished" => Self::Finished, 3375 "buzz.bookhive.defs#reading" => Self::Reading, 3376 "buzz.bookhive.defs#wantToRead" => Self::WantToRead, 3377 "buzz.bookhive.defs#abandoned" => Self::Abandoned, 3378 "buzz.bookhive.defs#owned" => Self::Owned, 3379 _ => Self::Other(jacquard_common::CowStr::from(s)), 3380 } 3381 } 3382} 3383 3384impl<'a> From<String> for UserBookStatus<'a> { 3385 fn from(s: String) -> Self { 3386 match s.as_str() { 3387 "buzz.bookhive.defs#finished" => Self::Finished, 3388 "buzz.bookhive.defs#reading" => Self::Reading, 3389 "buzz.bookhive.defs#wantToRead" => Self::WantToRead, 3390 "buzz.bookhive.defs#abandoned" => Self::Abandoned, 3391 "buzz.bookhive.defs#owned" => Self::Owned, 3392 _ => Self::Other(jacquard_common::CowStr::from(s)), 3393 } 3394 } 3395} 3396 3397impl<'a> core::fmt::Display for UserBookStatus<'a> { 3398 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 3399 write!(f, "{}", self.as_str()) 3400 } 3401} 3402 3403impl<'a> AsRef<str> for UserBookStatus<'a> { 3404 fn as_ref(&self) -> &str { 3405 self.as_str() 3406 } 3407} 3408 3409impl<'a> serde::Serialize for UserBookStatus<'a> { 3410 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> 3411 where 3412 S: serde::Serializer, 3413 { 3414 serializer.serialize_str(self.as_str()) 3415 } 3416} 3417 3418impl<'de, 'a> serde::Deserialize<'de> for UserBookStatus<'a> 3419where 3420 'de: 'a, 3421{ 3422 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> 3423 where 3424 D: serde::Deserializer<'de>, 3425 { 3426 let s = <&'de str>::deserialize(deserializer)?; 3427 Ok(Self::from(s)) 3428 } 3429} 3430 3431impl<'a> Default for UserBookStatus<'a> { 3432 fn default() -> Self { 3433 Self::Other(Default::default()) 3434 } 3435} 3436 3437impl jacquard_common::IntoStatic for UserBookStatus<'_> { 3438 type Output = UserBookStatus<'static>; 3439 fn into_static(self) -> Self::Output { 3440 match self { 3441 UserBookStatus::Finished => UserBookStatus::Finished, 3442 UserBookStatus::Reading => UserBookStatus::Reading, 3443 UserBookStatus::WantToRead => UserBookStatus::WantToRead, 3444 UserBookStatus::Abandoned => UserBookStatus::Abandoned, 3445 UserBookStatus::Owned => UserBookStatus::Owned, 3446 UserBookStatus::Other(v) => UserBookStatus::Other(v.into_static()), 3447 } 3448 } 3449} 3450 3451impl<'a> ::jacquard_lexicon::schema::LexiconSchema for UserBook<'a> { 3452 fn nsid() -> &'static str { 3453 "buzz.bookhive.defs" 3454 } 3455 fn def_name() -> &'static str { 3456 "userBook" 3457 } 3458 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { 3459 lexicon_doc_buzz_bookhive_defs() 3460 } 3461 fn validate( 3462 &self, 3463 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { 3464 { 3465 let value = &self.authors; 3466 #[allow(unused_comparisons)] 3467 if <str>::len(value.as_ref()) > 2048usize { 3468 return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength { 3469 path: ::jacquard_lexicon::validation::ValidationPath::from_field( 3470 "authors", 3471 ), 3472 max: 2048usize, 3473 actual: <str>::len(value.as_ref()), 3474 }); 3475 } 3476 } 3477 { 3478 let value = &self.authors; 3479 #[allow(unused_comparisons)] 3480 if <str>::len(value.as_ref()) < 1usize { 3481 return Err(::jacquard_lexicon::validation::ConstraintError::MinLength { 3482 path: ::jacquard_lexicon::validation::ValidationPath::from_field( 3483 "authors", 3484 ), 3485 min: 1usize, 3486 actual: <str>::len(value.as_ref()), 3487 }); 3488 } 3489 } 3490 if let Some(ref value) = self.description { 3491 #[allow(unused_comparisons)] 3492 if <str>::len(value.as_ref()) > 5000usize { 3493 return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength { 3494 path: ::jacquard_lexicon::validation::ValidationPath::from_field( 3495 "description", 3496 ), 3497 max: 5000usize, 3498 actual: <str>::len(value.as_ref()), 3499 }); 3500 } 3501 } 3502 if let Some(ref value) = self.rating { 3503 if *value > 1000i64 { 3504 return Err(::jacquard_lexicon::validation::ConstraintError::Maximum { 3505 path: ::jacquard_lexicon::validation::ValidationPath::from_field( 3506 "rating", 3507 ), 3508 max: 1000i64, 3509 actual: *value, 3510 }); 3511 } 3512 } 3513 if let Some(ref value) = self.rating { 3514 if *value < 0i64 { 3515 return Err(::jacquard_lexicon::validation::ConstraintError::Minimum { 3516 path: ::jacquard_lexicon::validation::ValidationPath::from_field( 3517 "rating", 3518 ), 3519 min: 0i64, 3520 actual: *value, 3521 }); 3522 } 3523 } 3524 if let Some(ref value) = self.review { 3525 { 3526 let count = ::unicode_segmentation::UnicodeSegmentation::graphemes( 3527 value.as_ref(), 3528 true, 3529 ) 3530 .count(); 3531 if count > 15000usize { 3532 return Err(::jacquard_lexicon::validation::ConstraintError::MaxGraphemes { 3533 path: ::jacquard_lexicon::validation::ValidationPath::from_field( 3534 "review", 3535 ), 3536 max: 15000usize, 3537 actual: count, 3538 }); 3539 } 3540 } 3541 } 3542 if let Some(ref value) = self.stars { 3543 if *value > 10i64 { 3544 return Err(::jacquard_lexicon::validation::ConstraintError::Maximum { 3545 path: ::jacquard_lexicon::validation::ValidationPath::from_field( 3546 "stars", 3547 ), 3548 max: 10i64, 3549 actual: *value, 3550 }); 3551 } 3552 } 3553 if let Some(ref value) = self.stars { 3554 if *value < 1i64 { 3555 return Err(::jacquard_lexicon::validation::ConstraintError::Minimum { 3556 path: ::jacquard_lexicon::validation::ValidationPath::from_field( 3557 "stars", 3558 ), 3559 min: 1i64, 3560 actual: *value, 3561 }); 3562 } 3563 } 3564 { 3565 let value = &self.title; 3566 #[allow(unused_comparisons)] 3567 if <str>::len(value.as_ref()) > 512usize { 3568 return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength { 3569 path: ::jacquard_lexicon::validation::ValidationPath::from_field( 3570 "title", 3571 ), 3572 max: 512usize, 3573 actual: <str>::len(value.as_ref()), 3574 }); 3575 } 3576 } 3577 { 3578 let value = &self.title; 3579 #[allow(unused_comparisons)] 3580 if <str>::len(value.as_ref()) < 1usize { 3581 return Err(::jacquard_lexicon::validation::ConstraintError::MinLength { 3582 path: ::jacquard_lexicon::validation::ValidationPath::from_field( 3583 "title", 3584 ), 3585 min: 1usize, 3586 actual: <str>::len(value.as_ref()), 3587 }); 3588 } 3589 } 3590 Ok(()) 3591 } 3592} 3593 3594/// User wants to read the book 3595#[derive( 3596 serde::Serialize, 3597 serde::Deserialize, 3598 Debug, 3599 Clone, 3600 PartialEq, 3601 Eq, 3602 Hash, 3603 jacquard_derive::IntoStatic 3604)] 3605pub struct WantToRead; 3606impl std::fmt::Display for WantToRead { 3607 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3608 write!(f, "wantToRead") 3609 } 3610}