atproto blogging
at main 1511 lines 59 kB view raw
1// @generated by jacquard-lexicon. DO NOT EDIT. 2// 3// Lexicon: sh.weaver.notification.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 get_subscription_updates; 9pub mod get_unread_count; 10pub mod list_notifications; 11pub mod update_seen; 12 13/// A notification for a user. 14#[jacquard_derive::lexicon] 15#[derive( 16 serde::Serialize, 17 serde::Deserialize, 18 Debug, 19 Clone, 20 PartialEq, 21 Eq, 22 jacquard_derive::IntoStatic 23)] 24#[serde(rename_all = "camelCase")] 25pub struct Notification<'a> { 26 #[serde(borrow)] 27 pub author: crate::sh_weaver::actor::ProfileViewBasic<'a>, 28 #[serde(borrow)] 29 pub cid: jacquard_common::types::string::Cid<'a>, 30 pub indexed_at: jacquard_common::types::string::Datetime, 31 pub is_read: bool, 32 #[serde(borrow)] 33 pub reason: crate::sh_weaver::notification::NotificationReason<'a>, 34 /// The subject of the notification (entry, notebook, etc). 35 #[serde(skip_serializing_if = "std::option::Option::is_none")] 36 #[serde(borrow)] 37 pub reason_subject: std::option::Option<jacquard_common::types::string::AtUri<'a>>, 38 #[serde(skip_serializing_if = "std::option::Option::is_none")] 39 #[serde(borrow)] 40 pub record: std::option::Option<jacquard_common::types::value::Data<'a>>, 41 #[serde(borrow)] 42 pub uri: jacquard_common::types::string::AtUri<'a>, 43} 44 45pub mod notification_state { 46 47 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 48 #[allow(unused)] 49 use ::core::marker::PhantomData; 50 mod sealed { 51 pub trait Sealed {} 52 } 53 /// State trait tracking which required fields have been set 54 pub trait State: sealed::Sealed { 55 type Cid; 56 type IndexedAt; 57 type IsRead; 58 type Author; 59 type Uri; 60 type Reason; 61 } 62 /// Empty state - all required fields are unset 63 pub struct Empty(()); 64 impl sealed::Sealed for Empty {} 65 impl State for Empty { 66 type Cid = Unset; 67 type IndexedAt = Unset; 68 type IsRead = Unset; 69 type Author = Unset; 70 type Uri = Unset; 71 type Reason = Unset; 72 } 73 ///State transition - sets the `cid` field to Set 74 pub struct SetCid<S: State = Empty>(PhantomData<fn() -> S>); 75 impl<S: State> sealed::Sealed for SetCid<S> {} 76 impl<S: State> State for SetCid<S> { 77 type Cid = Set<members::cid>; 78 type IndexedAt = S::IndexedAt; 79 type IsRead = S::IsRead; 80 type Author = S::Author; 81 type Uri = S::Uri; 82 type Reason = S::Reason; 83 } 84 ///State transition - sets the `indexed_at` field to Set 85 pub struct SetIndexedAt<S: State = Empty>(PhantomData<fn() -> S>); 86 impl<S: State> sealed::Sealed for SetIndexedAt<S> {} 87 impl<S: State> State for SetIndexedAt<S> { 88 type Cid = S::Cid; 89 type IndexedAt = Set<members::indexed_at>; 90 type IsRead = S::IsRead; 91 type Author = S::Author; 92 type Uri = S::Uri; 93 type Reason = S::Reason; 94 } 95 ///State transition - sets the `is_read` field to Set 96 pub struct SetIsRead<S: State = Empty>(PhantomData<fn() -> S>); 97 impl<S: State> sealed::Sealed for SetIsRead<S> {} 98 impl<S: State> State for SetIsRead<S> { 99 type Cid = S::Cid; 100 type IndexedAt = S::IndexedAt; 101 type IsRead = Set<members::is_read>; 102 type Author = S::Author; 103 type Uri = S::Uri; 104 type Reason = S::Reason; 105 } 106 ///State transition - sets the `author` field to Set 107 pub struct SetAuthor<S: State = Empty>(PhantomData<fn() -> S>); 108 impl<S: State> sealed::Sealed for SetAuthor<S> {} 109 impl<S: State> State for SetAuthor<S> { 110 type Cid = S::Cid; 111 type IndexedAt = S::IndexedAt; 112 type IsRead = S::IsRead; 113 type Author = Set<members::author>; 114 type Uri = S::Uri; 115 type Reason = S::Reason; 116 } 117 ///State transition - sets the `uri` field to Set 118 pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>); 119 impl<S: State> sealed::Sealed for SetUri<S> {} 120 impl<S: State> State for SetUri<S> { 121 type Cid = S::Cid; 122 type IndexedAt = S::IndexedAt; 123 type IsRead = S::IsRead; 124 type Author = S::Author; 125 type Uri = Set<members::uri>; 126 type Reason = S::Reason; 127 } 128 ///State transition - sets the `reason` field to Set 129 pub struct SetReason<S: State = Empty>(PhantomData<fn() -> S>); 130 impl<S: State> sealed::Sealed for SetReason<S> {} 131 impl<S: State> State for SetReason<S> { 132 type Cid = S::Cid; 133 type IndexedAt = S::IndexedAt; 134 type IsRead = S::IsRead; 135 type Author = S::Author; 136 type Uri = S::Uri; 137 type Reason = Set<members::reason>; 138 } 139 /// Marker types for field names 140 #[allow(non_camel_case_types)] 141 pub mod members { 142 ///Marker type for the `cid` field 143 pub struct cid(()); 144 ///Marker type for the `indexed_at` field 145 pub struct indexed_at(()); 146 ///Marker type for the `is_read` field 147 pub struct is_read(()); 148 ///Marker type for the `author` field 149 pub struct author(()); 150 ///Marker type for the `uri` field 151 pub struct uri(()); 152 ///Marker type for the `reason` field 153 pub struct reason(()); 154 } 155} 156 157/// Builder for constructing an instance of this type 158pub struct NotificationBuilder<'a, S: notification_state::State> { 159 _phantom_state: ::core::marker::PhantomData<fn() -> S>, 160 __unsafe_private_named: ( 161 ::core::option::Option<crate::sh_weaver::actor::ProfileViewBasic<'a>>, 162 ::core::option::Option<jacquard_common::types::string::Cid<'a>>, 163 ::core::option::Option<jacquard_common::types::string::Datetime>, 164 ::core::option::Option<bool>, 165 ::core::option::Option<crate::sh_weaver::notification::NotificationReason<'a>>, 166 ::core::option::Option<jacquard_common::types::string::AtUri<'a>>, 167 ::core::option::Option<jacquard_common::types::value::Data<'a>>, 168 ::core::option::Option<jacquard_common::types::string::AtUri<'a>>, 169 ), 170 _phantom: ::core::marker::PhantomData<&'a ()>, 171} 172 173impl<'a> Notification<'a> { 174 /// Create a new builder for this type 175 pub fn new() -> NotificationBuilder<'a, notification_state::Empty> { 176 NotificationBuilder::new() 177 } 178} 179 180impl<'a> NotificationBuilder<'a, notification_state::Empty> { 181 /// Create a new builder with all fields unset 182 pub fn new() -> Self { 183 NotificationBuilder { 184 _phantom_state: ::core::marker::PhantomData, 185 __unsafe_private_named: (None, None, None, None, None, None, None, None), 186 _phantom: ::core::marker::PhantomData, 187 } 188 } 189} 190 191impl<'a, S> NotificationBuilder<'a, S> 192where 193 S: notification_state::State, 194 S::Author: notification_state::IsUnset, 195{ 196 /// Set the `author` field (required) 197 pub fn author( 198 mut self, 199 value: impl Into<crate::sh_weaver::actor::ProfileViewBasic<'a>>, 200 ) -> NotificationBuilder<'a, notification_state::SetAuthor<S>> { 201 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); 202 NotificationBuilder { 203 _phantom_state: ::core::marker::PhantomData, 204 __unsafe_private_named: self.__unsafe_private_named, 205 _phantom: ::core::marker::PhantomData, 206 } 207 } 208} 209 210impl<'a, S> NotificationBuilder<'a, S> 211where 212 S: notification_state::State, 213 S::Cid: notification_state::IsUnset, 214{ 215 /// Set the `cid` field (required) 216 pub fn cid( 217 mut self, 218 value: impl Into<jacquard_common::types::string::Cid<'a>>, 219 ) -> NotificationBuilder<'a, notification_state::SetCid<S>> { 220 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); 221 NotificationBuilder { 222 _phantom_state: ::core::marker::PhantomData, 223 __unsafe_private_named: self.__unsafe_private_named, 224 _phantom: ::core::marker::PhantomData, 225 } 226 } 227} 228 229impl<'a, S> NotificationBuilder<'a, S> 230where 231 S: notification_state::State, 232 S::IndexedAt: notification_state::IsUnset, 233{ 234 /// Set the `indexedAt` field (required) 235 pub fn indexed_at( 236 mut self, 237 value: impl Into<jacquard_common::types::string::Datetime>, 238 ) -> NotificationBuilder<'a, notification_state::SetIndexedAt<S>> { 239 self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into()); 240 NotificationBuilder { 241 _phantom_state: ::core::marker::PhantomData, 242 __unsafe_private_named: self.__unsafe_private_named, 243 _phantom: ::core::marker::PhantomData, 244 } 245 } 246} 247 248impl<'a, S> NotificationBuilder<'a, S> 249where 250 S: notification_state::State, 251 S::IsRead: notification_state::IsUnset, 252{ 253 /// Set the `isRead` field (required) 254 pub fn is_read( 255 mut self, 256 value: impl Into<bool>, 257 ) -> NotificationBuilder<'a, notification_state::SetIsRead<S>> { 258 self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into()); 259 NotificationBuilder { 260 _phantom_state: ::core::marker::PhantomData, 261 __unsafe_private_named: self.__unsafe_private_named, 262 _phantom: ::core::marker::PhantomData, 263 } 264 } 265} 266 267impl<'a, S> NotificationBuilder<'a, S> 268where 269 S: notification_state::State, 270 S::Reason: notification_state::IsUnset, 271{ 272 /// Set the `reason` field (required) 273 pub fn reason( 274 mut self, 275 value: impl Into<crate::sh_weaver::notification::NotificationReason<'a>>, 276 ) -> NotificationBuilder<'a, notification_state::SetReason<S>> { 277 self.__unsafe_private_named.4 = ::core::option::Option::Some(value.into()); 278 NotificationBuilder { 279 _phantom_state: ::core::marker::PhantomData, 280 __unsafe_private_named: self.__unsafe_private_named, 281 _phantom: ::core::marker::PhantomData, 282 } 283 } 284} 285 286impl<'a, S: notification_state::State> NotificationBuilder<'a, S> { 287 /// Set the `reasonSubject` field (optional) 288 pub fn reason_subject( 289 mut self, 290 value: impl Into<Option<jacquard_common::types::string::AtUri<'a>>>, 291 ) -> Self { 292 self.__unsafe_private_named.5 = value.into(); 293 self 294 } 295 /// Set the `reasonSubject` field to an Option value (optional) 296 pub fn maybe_reason_subject( 297 mut self, 298 value: Option<jacquard_common::types::string::AtUri<'a>>, 299 ) -> Self { 300 self.__unsafe_private_named.5 = value; 301 self 302 } 303} 304 305impl<'a, S: notification_state::State> NotificationBuilder<'a, S> { 306 /// Set the `record` field (optional) 307 pub fn record( 308 mut self, 309 value: impl Into<Option<jacquard_common::types::value::Data<'a>>>, 310 ) -> Self { 311 self.__unsafe_private_named.6 = value.into(); 312 self 313 } 314 /// Set the `record` field to an Option value (optional) 315 pub fn maybe_record( 316 mut self, 317 value: Option<jacquard_common::types::value::Data<'a>>, 318 ) -> Self { 319 self.__unsafe_private_named.6 = value; 320 self 321 } 322} 323 324impl<'a, S> NotificationBuilder<'a, S> 325where 326 S: notification_state::State, 327 S::Uri: notification_state::IsUnset, 328{ 329 /// Set the `uri` field (required) 330 pub fn uri( 331 mut self, 332 value: impl Into<jacquard_common::types::string::AtUri<'a>>, 333 ) -> NotificationBuilder<'a, notification_state::SetUri<S>> { 334 self.__unsafe_private_named.7 = ::core::option::Option::Some(value.into()); 335 NotificationBuilder { 336 _phantom_state: ::core::marker::PhantomData, 337 __unsafe_private_named: self.__unsafe_private_named, 338 _phantom: ::core::marker::PhantomData, 339 } 340 } 341} 342 343impl<'a, S> NotificationBuilder<'a, S> 344where 345 S: notification_state::State, 346 S::Cid: notification_state::IsSet, 347 S::IndexedAt: notification_state::IsSet, 348 S::IsRead: notification_state::IsSet, 349 S::Author: notification_state::IsSet, 350 S::Uri: notification_state::IsSet, 351 S::Reason: notification_state::IsSet, 352{ 353 /// Build the final struct 354 pub fn build(self) -> Notification<'a> { 355 Notification { 356 author: self.__unsafe_private_named.0.unwrap(), 357 cid: self.__unsafe_private_named.1.unwrap(), 358 indexed_at: self.__unsafe_private_named.2.unwrap(), 359 is_read: self.__unsafe_private_named.3.unwrap(), 360 reason: self.__unsafe_private_named.4.unwrap(), 361 reason_subject: self.__unsafe_private_named.5, 362 record: self.__unsafe_private_named.6, 363 uri: self.__unsafe_private_named.7.unwrap(), 364 extra_data: Default::default(), 365 } 366 } 367 /// Build the final struct with custom extra_data 368 pub fn build_with_data( 369 self, 370 extra_data: std::collections::BTreeMap< 371 jacquard_common::smol_str::SmolStr, 372 jacquard_common::types::value::Data<'a>, 373 >, 374 ) -> Notification<'a> { 375 Notification { 376 author: self.__unsafe_private_named.0.unwrap(), 377 cid: self.__unsafe_private_named.1.unwrap(), 378 indexed_at: self.__unsafe_private_named.2.unwrap(), 379 is_read: self.__unsafe_private_named.3.unwrap(), 380 reason: self.__unsafe_private_named.4.unwrap(), 381 reason_subject: self.__unsafe_private_named.5, 382 record: self.__unsafe_private_named.6, 383 uri: self.__unsafe_private_named.7.unwrap(), 384 extra_data: Some(extra_data), 385 } 386 } 387} 388 389fn lexicon_doc_sh_weaver_notification_defs() -> ::jacquard_lexicon::lexicon::LexiconDoc< 390 'static, 391> { 392 ::jacquard_lexicon::lexicon::LexiconDoc { 393 lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, 394 id: ::jacquard_common::CowStr::new_static("sh.weaver.notification.defs"), 395 revision: None, 396 description: None, 397 defs: { 398 let mut map = ::alloc::collections::BTreeMap::new(); 399 map.insert( 400 ::jacquard_common::smol_str::SmolStr::new_static("notification"), 401 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 402 description: Some( 403 ::jacquard_common::CowStr::new_static( 404 "A notification for a user.", 405 ), 406 ), 407 required: Some( 408 vec![ 409 ::jacquard_common::smol_str::SmolStr::new_static("uri"), 410 ::jacquard_common::smol_str::SmolStr::new_static("cid"), 411 ::jacquard_common::smol_str::SmolStr::new_static("author"), 412 ::jacquard_common::smol_str::SmolStr::new_static("reason"), 413 ::jacquard_common::smol_str::SmolStr::new_static("isRead"), 414 ::jacquard_common::smol_str::SmolStr::new_static("indexedAt") 415 ], 416 ), 417 nullable: None, 418 properties: { 419 #[allow(unused_mut)] 420 let mut map = ::alloc::collections::BTreeMap::new(); 421 map.insert( 422 ::jacquard_common::smol_str::SmolStr::new_static("author"), 423 ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { 424 description: None, 425 r#ref: ::jacquard_common::CowStr::new_static( 426 "sh.weaver.actor.defs#profileViewBasic", 427 ), 428 }), 429 ); 430 map.insert( 431 ::jacquard_common::smol_str::SmolStr::new_static("cid"), 432 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 433 description: None, 434 format: Some( 435 ::jacquard_lexicon::lexicon::LexStringFormat::Cid, 436 ), 437 default: None, 438 min_length: None, 439 max_length: None, 440 min_graphemes: None, 441 max_graphemes: None, 442 r#enum: None, 443 r#const: None, 444 known_values: None, 445 }), 446 ); 447 map.insert( 448 ::jacquard_common::smol_str::SmolStr::new_static( 449 "indexedAt", 450 ), 451 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 452 description: None, 453 format: Some( 454 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime, 455 ), 456 default: None, 457 min_length: None, 458 max_length: None, 459 min_graphemes: None, 460 max_graphemes: None, 461 r#enum: None, 462 r#const: None, 463 known_values: None, 464 }), 465 ); 466 map.insert( 467 ::jacquard_common::smol_str::SmolStr::new_static("isRead"), 468 ::jacquard_lexicon::lexicon::LexObjectProperty::Boolean(::jacquard_lexicon::lexicon::LexBoolean { 469 description: None, 470 default: None, 471 r#const: None, 472 }), 473 ); 474 map.insert( 475 ::jacquard_common::smol_str::SmolStr::new_static("reason"), 476 ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { 477 description: None, 478 r#ref: ::jacquard_common::CowStr::new_static( 479 "#notificationReason", 480 ), 481 }), 482 ); 483 map.insert( 484 ::jacquard_common::smol_str::SmolStr::new_static( 485 "reasonSubject", 486 ), 487 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 488 description: Some( 489 ::jacquard_common::CowStr::new_static( 490 "The subject of the notification (entry, notebook, etc).", 491 ), 492 ), 493 format: Some( 494 ::jacquard_lexicon::lexicon::LexStringFormat::AtUri, 495 ), 496 default: None, 497 min_length: None, 498 max_length: None, 499 min_graphemes: None, 500 max_graphemes: None, 501 r#enum: None, 502 r#const: None, 503 known_values: None, 504 }), 505 ); 506 map.insert( 507 ::jacquard_common::smol_str::SmolStr::new_static("record"), 508 ::jacquard_lexicon::lexicon::LexObjectProperty::Unknown(::jacquard_lexicon::lexicon::LexUnknown { 509 description: None, 510 }), 511 ); 512 map.insert( 513 ::jacquard_common::smol_str::SmolStr::new_static("uri"), 514 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 515 description: None, 516 format: Some( 517 ::jacquard_lexicon::lexicon::LexStringFormat::AtUri, 518 ), 519 default: None, 520 min_length: None, 521 max_length: None, 522 min_graphemes: None, 523 max_graphemes: None, 524 r#enum: None, 525 r#const: None, 526 known_values: None, 527 }), 528 ); 529 map 530 }, 531 }), 532 ); 533 map.insert( 534 ::jacquard_common::smol_str::SmolStr::new_static("notificationGroup"), 535 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 536 description: Some( 537 ::jacquard_common::CowStr::new_static( 538 "Grouped notifications (e.g., '5 people liked your entry').", 539 ), 540 ), 541 required: Some( 542 vec![ 543 ::jacquard_common::smol_str::SmolStr::new_static("reason"), 544 ::jacquard_common::smol_str::SmolStr::new_static("subject"), 545 ::jacquard_common::smol_str::SmolStr::new_static("count"), 546 ::jacquard_common::smol_str::SmolStr::new_static("actors"), 547 ::jacquard_common::smol_str::SmolStr::new_static("mostRecentAt") 548 ], 549 ), 550 nullable: None, 551 properties: { 552 #[allow(unused_mut)] 553 let mut map = ::alloc::collections::BTreeMap::new(); 554 map.insert( 555 ::jacquard_common::smol_str::SmolStr::new_static("actors"), 556 ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray { 557 description: Some( 558 ::jacquard_common::CowStr::new_static( 559 "Most recent actors (up to 5).", 560 ), 561 ), 562 items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef { 563 description: None, 564 r#ref: ::jacquard_common::CowStr::new_static( 565 "sh.weaver.actor.defs#profileViewBasic", 566 ), 567 }), 568 min_length: None, 569 max_length: Some(5usize), 570 }), 571 ); 572 map.insert( 573 ::jacquard_common::smol_str::SmolStr::new_static("count"), 574 ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger { 575 description: None, 576 default: None, 577 minimum: None, 578 maximum: None, 579 r#enum: None, 580 r#const: None, 581 }), 582 ); 583 map.insert( 584 ::jacquard_common::smol_str::SmolStr::new_static("isRead"), 585 ::jacquard_lexicon::lexicon::LexObjectProperty::Boolean(::jacquard_lexicon::lexicon::LexBoolean { 586 description: None, 587 default: None, 588 r#const: None, 589 }), 590 ); 591 map.insert( 592 ::jacquard_common::smol_str::SmolStr::new_static( 593 "mostRecentAt", 594 ), 595 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 596 description: None, 597 format: Some( 598 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime, 599 ), 600 default: None, 601 min_length: None, 602 max_length: None, 603 min_graphemes: None, 604 max_graphemes: None, 605 r#enum: None, 606 r#const: None, 607 known_values: None, 608 }), 609 ); 610 map.insert( 611 ::jacquard_common::smol_str::SmolStr::new_static("reason"), 612 ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { 613 description: None, 614 r#ref: ::jacquard_common::CowStr::new_static( 615 "#notificationReason", 616 ), 617 }), 618 ); 619 map.insert( 620 ::jacquard_common::smol_str::SmolStr::new_static("subject"), 621 ::jacquard_lexicon::lexicon::LexObjectProperty::Union(::jacquard_lexicon::lexicon::LexRefUnion { 622 description: None, 623 refs: vec![ 624 ::jacquard_common::CowStr::new_static("sh.weaver.notebook.defs#notebookView"), 625 ::jacquard_common::CowStr::new_static("sh.weaver.notebook.defs#entryView") 626 ], 627 closed: None, 628 }), 629 ); 630 map 631 }, 632 }), 633 ); 634 map.insert( 635 ::jacquard_common::smol_str::SmolStr::new_static("notificationReason"), 636 ::jacquard_lexicon::lexicon::LexUserType::String(::jacquard_lexicon::lexicon::LexString { 637 description: Some( 638 ::jacquard_common::CowStr::new_static( 639 "Why this notification was generated.", 640 ), 641 ), 642 format: None, 643 default: None, 644 min_length: None, 645 max_length: None, 646 min_graphemes: None, 647 max_graphemes: None, 648 r#enum: None, 649 r#const: None, 650 known_values: None, 651 }), 652 ); 653 map.insert( 654 ::jacquard_common::smol_str::SmolStr::new_static( 655 "subscriptionUpdateView", 656 ), 657 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 658 description: Some( 659 ::jacquard_common::CowStr::new_static( 660 "New content from a notebook subscription.", 661 ), 662 ), 663 required: Some( 664 vec![ 665 ::jacquard_common::smol_str::SmolStr::new_static("notebook"), 666 ::jacquard_common::smol_str::SmolStr::new_static("newEntries"), 667 ::jacquard_common::smol_str::SmolStr::new_static("updatedAt") 668 ], 669 ), 670 nullable: None, 671 properties: { 672 #[allow(unused_mut)] 673 let mut map = ::alloc::collections::BTreeMap::new(); 674 map.insert( 675 ::jacquard_common::smol_str::SmolStr::new_static( 676 "newEntries", 677 ), 678 ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray { 679 description: Some( 680 ::jacquard_common::CowStr::new_static( 681 "New entries since last check.", 682 ), 683 ), 684 items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef { 685 description: None, 686 r#ref: ::jacquard_common::CowStr::new_static( 687 "sh.weaver.notebook.defs#entryView", 688 ), 689 }), 690 min_length: None, 691 max_length: None, 692 }), 693 ); 694 map.insert( 695 ::jacquard_common::smol_str::SmolStr::new_static("notebook"), 696 ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { 697 description: None, 698 r#ref: ::jacquard_common::CowStr::new_static( 699 "sh.weaver.notebook.defs#notebookView", 700 ), 701 }), 702 ); 703 map.insert( 704 ::jacquard_common::smol_str::SmolStr::new_static( 705 "updatedAt", 706 ), 707 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { 708 description: None, 709 format: Some( 710 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime, 711 ), 712 default: None, 713 min_length: None, 714 max_length: None, 715 min_graphemes: None, 716 max_graphemes: None, 717 r#enum: None, 718 r#const: None, 719 known_values: None, 720 }), 721 ); 722 map.insert( 723 ::jacquard_common::smol_str::SmolStr::new_static( 724 "updatedEntries", 725 ), 726 ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray { 727 description: Some( 728 ::jacquard_common::CowStr::new_static( 729 "Entries that were updated.", 730 ), 731 ), 732 items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef { 733 description: None, 734 r#ref: ::jacquard_common::CowStr::new_static( 735 "sh.weaver.notebook.defs#entryView", 736 ), 737 }), 738 min_length: None, 739 max_length: None, 740 }), 741 ); 742 map 743 }, 744 }), 745 ); 746 map 747 }, 748 } 749} 750 751impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Notification<'a> { 752 fn nsid() -> &'static str { 753 "sh.weaver.notification.defs" 754 } 755 fn def_name() -> &'static str { 756 "notification" 757 } 758 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { 759 lexicon_doc_sh_weaver_notification_defs() 760 } 761 fn validate( 762 &self, 763 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { 764 Ok(()) 765 } 766} 767 768/// Grouped notifications (e.g., '5 people liked your entry'). 769#[jacquard_derive::lexicon] 770#[derive( 771 serde::Serialize, 772 serde::Deserialize, 773 Debug, 774 Clone, 775 PartialEq, 776 Eq, 777 jacquard_derive::IntoStatic 778)] 779#[serde(rename_all = "camelCase")] 780pub struct NotificationGroup<'a> { 781 /// Most recent actors (up to 5). 782 #[serde(borrow)] 783 pub actors: Vec<crate::sh_weaver::actor::ProfileViewBasic<'a>>, 784 pub count: i64, 785 #[serde(skip_serializing_if = "std::option::Option::is_none")] 786 pub is_read: std::option::Option<bool>, 787 pub most_recent_at: jacquard_common::types::string::Datetime, 788 #[serde(borrow)] 789 pub reason: crate::sh_weaver::notification::NotificationReason<'a>, 790 #[serde(borrow)] 791 pub subject: NotificationGroupSubject<'a>, 792} 793 794pub mod notification_group_state { 795 796 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 797 #[allow(unused)] 798 use ::core::marker::PhantomData; 799 mod sealed { 800 pub trait Sealed {} 801 } 802 /// State trait tracking which required fields have been set 803 pub trait State: sealed::Sealed { 804 type Count; 805 type Reason; 806 type Actors; 807 type Subject; 808 type MostRecentAt; 809 } 810 /// Empty state - all required fields are unset 811 pub struct Empty(()); 812 impl sealed::Sealed for Empty {} 813 impl State for Empty { 814 type Count = Unset; 815 type Reason = Unset; 816 type Actors = Unset; 817 type Subject = Unset; 818 type MostRecentAt = Unset; 819 } 820 ///State transition - sets the `count` field to Set 821 pub struct SetCount<S: State = Empty>(PhantomData<fn() -> S>); 822 impl<S: State> sealed::Sealed for SetCount<S> {} 823 impl<S: State> State for SetCount<S> { 824 type Count = Set<members::count>; 825 type Reason = S::Reason; 826 type Actors = S::Actors; 827 type Subject = S::Subject; 828 type MostRecentAt = S::MostRecentAt; 829 } 830 ///State transition - sets the `reason` field to Set 831 pub struct SetReason<S: State = Empty>(PhantomData<fn() -> S>); 832 impl<S: State> sealed::Sealed for SetReason<S> {} 833 impl<S: State> State for SetReason<S> { 834 type Count = S::Count; 835 type Reason = Set<members::reason>; 836 type Actors = S::Actors; 837 type Subject = S::Subject; 838 type MostRecentAt = S::MostRecentAt; 839 } 840 ///State transition - sets the `actors` field to Set 841 pub struct SetActors<S: State = Empty>(PhantomData<fn() -> S>); 842 impl<S: State> sealed::Sealed for SetActors<S> {} 843 impl<S: State> State for SetActors<S> { 844 type Count = S::Count; 845 type Reason = S::Reason; 846 type Actors = Set<members::actors>; 847 type Subject = S::Subject; 848 type MostRecentAt = S::MostRecentAt; 849 } 850 ///State transition - sets the `subject` field to Set 851 pub struct SetSubject<S: State = Empty>(PhantomData<fn() -> S>); 852 impl<S: State> sealed::Sealed for SetSubject<S> {} 853 impl<S: State> State for SetSubject<S> { 854 type Count = S::Count; 855 type Reason = S::Reason; 856 type Actors = S::Actors; 857 type Subject = Set<members::subject>; 858 type MostRecentAt = S::MostRecentAt; 859 } 860 ///State transition - sets the `most_recent_at` field to Set 861 pub struct SetMostRecentAt<S: State = Empty>(PhantomData<fn() -> S>); 862 impl<S: State> sealed::Sealed for SetMostRecentAt<S> {} 863 impl<S: State> State for SetMostRecentAt<S> { 864 type Count = S::Count; 865 type Reason = S::Reason; 866 type Actors = S::Actors; 867 type Subject = S::Subject; 868 type MostRecentAt = Set<members::most_recent_at>; 869 } 870 /// Marker types for field names 871 #[allow(non_camel_case_types)] 872 pub mod members { 873 ///Marker type for the `count` field 874 pub struct count(()); 875 ///Marker type for the `reason` field 876 pub struct reason(()); 877 ///Marker type for the `actors` field 878 pub struct actors(()); 879 ///Marker type for the `subject` field 880 pub struct subject(()); 881 ///Marker type for the `most_recent_at` field 882 pub struct most_recent_at(()); 883 } 884} 885 886/// Builder for constructing an instance of this type 887pub struct NotificationGroupBuilder<'a, S: notification_group_state::State> { 888 _phantom_state: ::core::marker::PhantomData<fn() -> S>, 889 __unsafe_private_named: ( 890 ::core::option::Option<Vec<crate::sh_weaver::actor::ProfileViewBasic<'a>>>, 891 ::core::option::Option<i64>, 892 ::core::option::Option<bool>, 893 ::core::option::Option<jacquard_common::types::string::Datetime>, 894 ::core::option::Option<crate::sh_weaver::notification::NotificationReason<'a>>, 895 ::core::option::Option<NotificationGroupSubject<'a>>, 896 ), 897 _phantom: ::core::marker::PhantomData<&'a ()>, 898} 899 900impl<'a> NotificationGroup<'a> { 901 /// Create a new builder for this type 902 pub fn new() -> NotificationGroupBuilder<'a, notification_group_state::Empty> { 903 NotificationGroupBuilder::new() 904 } 905} 906 907impl<'a> NotificationGroupBuilder<'a, notification_group_state::Empty> { 908 /// Create a new builder with all fields unset 909 pub fn new() -> Self { 910 NotificationGroupBuilder { 911 _phantom_state: ::core::marker::PhantomData, 912 __unsafe_private_named: (None, None, None, None, None, None), 913 _phantom: ::core::marker::PhantomData, 914 } 915 } 916} 917 918impl<'a, S> NotificationGroupBuilder<'a, S> 919where 920 S: notification_group_state::State, 921 S::Actors: notification_group_state::IsUnset, 922{ 923 /// Set the `actors` field (required) 924 pub fn actors( 925 mut self, 926 value: impl Into<Vec<crate::sh_weaver::actor::ProfileViewBasic<'a>>>, 927 ) -> NotificationGroupBuilder<'a, notification_group_state::SetActors<S>> { 928 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); 929 NotificationGroupBuilder { 930 _phantom_state: ::core::marker::PhantomData, 931 __unsafe_private_named: self.__unsafe_private_named, 932 _phantom: ::core::marker::PhantomData, 933 } 934 } 935} 936 937impl<'a, S> NotificationGroupBuilder<'a, S> 938where 939 S: notification_group_state::State, 940 S::Count: notification_group_state::IsUnset, 941{ 942 /// Set the `count` field (required) 943 pub fn count( 944 mut self, 945 value: impl Into<i64>, 946 ) -> NotificationGroupBuilder<'a, notification_group_state::SetCount<S>> { 947 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); 948 NotificationGroupBuilder { 949 _phantom_state: ::core::marker::PhantomData, 950 __unsafe_private_named: self.__unsafe_private_named, 951 _phantom: ::core::marker::PhantomData, 952 } 953 } 954} 955 956impl<'a, S: notification_group_state::State> NotificationGroupBuilder<'a, S> { 957 /// Set the `isRead` field (optional) 958 pub fn is_read(mut self, value: impl Into<Option<bool>>) -> Self { 959 self.__unsafe_private_named.2 = value.into(); 960 self 961 } 962 /// Set the `isRead` field to an Option value (optional) 963 pub fn maybe_is_read(mut self, value: Option<bool>) -> Self { 964 self.__unsafe_private_named.2 = value; 965 self 966 } 967} 968 969impl<'a, S> NotificationGroupBuilder<'a, S> 970where 971 S: notification_group_state::State, 972 S::MostRecentAt: notification_group_state::IsUnset, 973{ 974 /// Set the `mostRecentAt` field (required) 975 pub fn most_recent_at( 976 mut self, 977 value: impl Into<jacquard_common::types::string::Datetime>, 978 ) -> NotificationGroupBuilder<'a, notification_group_state::SetMostRecentAt<S>> { 979 self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into()); 980 NotificationGroupBuilder { 981 _phantom_state: ::core::marker::PhantomData, 982 __unsafe_private_named: self.__unsafe_private_named, 983 _phantom: ::core::marker::PhantomData, 984 } 985 } 986} 987 988impl<'a, S> NotificationGroupBuilder<'a, S> 989where 990 S: notification_group_state::State, 991 S::Reason: notification_group_state::IsUnset, 992{ 993 /// Set the `reason` field (required) 994 pub fn reason( 995 mut self, 996 value: impl Into<crate::sh_weaver::notification::NotificationReason<'a>>, 997 ) -> NotificationGroupBuilder<'a, notification_group_state::SetReason<S>> { 998 self.__unsafe_private_named.4 = ::core::option::Option::Some(value.into()); 999 NotificationGroupBuilder { 1000 _phantom_state: ::core::marker::PhantomData, 1001 __unsafe_private_named: self.__unsafe_private_named, 1002 _phantom: ::core::marker::PhantomData, 1003 } 1004 } 1005} 1006 1007impl<'a, S> NotificationGroupBuilder<'a, S> 1008where 1009 S: notification_group_state::State, 1010 S::Subject: notification_group_state::IsUnset, 1011{ 1012 /// Set the `subject` field (required) 1013 pub fn subject( 1014 mut self, 1015 value: impl Into<NotificationGroupSubject<'a>>, 1016 ) -> NotificationGroupBuilder<'a, notification_group_state::SetSubject<S>> { 1017 self.__unsafe_private_named.5 = ::core::option::Option::Some(value.into()); 1018 NotificationGroupBuilder { 1019 _phantom_state: ::core::marker::PhantomData, 1020 __unsafe_private_named: self.__unsafe_private_named, 1021 _phantom: ::core::marker::PhantomData, 1022 } 1023 } 1024} 1025 1026impl<'a, S> NotificationGroupBuilder<'a, S> 1027where 1028 S: notification_group_state::State, 1029 S::Count: notification_group_state::IsSet, 1030 S::Reason: notification_group_state::IsSet, 1031 S::Actors: notification_group_state::IsSet, 1032 S::Subject: notification_group_state::IsSet, 1033 S::MostRecentAt: notification_group_state::IsSet, 1034{ 1035 /// Build the final struct 1036 pub fn build(self) -> NotificationGroup<'a> { 1037 NotificationGroup { 1038 actors: self.__unsafe_private_named.0.unwrap(), 1039 count: self.__unsafe_private_named.1.unwrap(), 1040 is_read: self.__unsafe_private_named.2, 1041 most_recent_at: self.__unsafe_private_named.3.unwrap(), 1042 reason: self.__unsafe_private_named.4.unwrap(), 1043 subject: self.__unsafe_private_named.5.unwrap(), 1044 extra_data: Default::default(), 1045 } 1046 } 1047 /// Build the final struct with custom extra_data 1048 pub fn build_with_data( 1049 self, 1050 extra_data: std::collections::BTreeMap< 1051 jacquard_common::smol_str::SmolStr, 1052 jacquard_common::types::value::Data<'a>, 1053 >, 1054 ) -> NotificationGroup<'a> { 1055 NotificationGroup { 1056 actors: self.__unsafe_private_named.0.unwrap(), 1057 count: self.__unsafe_private_named.1.unwrap(), 1058 is_read: self.__unsafe_private_named.2, 1059 most_recent_at: self.__unsafe_private_named.3.unwrap(), 1060 reason: self.__unsafe_private_named.4.unwrap(), 1061 subject: self.__unsafe_private_named.5.unwrap(), 1062 extra_data: Some(extra_data), 1063 } 1064 } 1065} 1066 1067#[jacquard_derive::open_union] 1068#[derive( 1069 serde::Serialize, 1070 serde::Deserialize, 1071 Debug, 1072 Clone, 1073 PartialEq, 1074 Eq, 1075 jacquard_derive::IntoStatic 1076)] 1077#[serde(tag = "$type")] 1078#[serde(bound(deserialize = "'de: 'a"))] 1079pub enum NotificationGroupSubject<'a> { 1080 #[serde(rename = "sh.weaver.notebook.defs#notebookView")] 1081 NotebookView(Box<crate::sh_weaver::notebook::NotebookView<'a>>), 1082 #[serde(rename = "sh.weaver.notebook.defs#entryView")] 1083 EntryView(Box<crate::sh_weaver::notebook::EntryView<'a>>), 1084} 1085 1086impl<'a> ::jacquard_lexicon::schema::LexiconSchema for NotificationGroup<'a> { 1087 fn nsid() -> &'static str { 1088 "sh.weaver.notification.defs" 1089 } 1090 fn def_name() -> &'static str { 1091 "notificationGroup" 1092 } 1093 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { 1094 lexicon_doc_sh_weaver_notification_defs() 1095 } 1096 fn validate( 1097 &self, 1098 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { 1099 { 1100 let value = &self.actors; 1101 #[allow(unused_comparisons)] 1102 if value.len() > 5usize { 1103 return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength { 1104 path: ::jacquard_lexicon::validation::ValidationPath::from_field( 1105 "actors", 1106 ), 1107 max: 5usize, 1108 actual: value.len(), 1109 }); 1110 } 1111 } 1112 Ok(()) 1113 } 1114} 1115 1116/// Why this notification was generated. 1117#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1118pub enum NotificationReason<'a> { 1119 Like, 1120 Bookmark, 1121 Follow, 1122 FollowAccept, 1123 Subscribe, 1124 SubscribeAccept, 1125 CollaborationInvite, 1126 CollaborationAccept, 1127 NewEntry, 1128 EntryUpdate, 1129 Mention, 1130 Tag, 1131 Comment, 1132 Other(jacquard_common::CowStr<'a>), 1133} 1134 1135impl<'a> NotificationReason<'a> { 1136 pub fn as_str(&self) -> &str { 1137 match self { 1138 Self::Like => "like", 1139 Self::Bookmark => "bookmark", 1140 Self::Follow => "follow", 1141 Self::FollowAccept => "followAccept", 1142 Self::Subscribe => "subscribe", 1143 Self::SubscribeAccept => "subscribeAccept", 1144 Self::CollaborationInvite => "collaborationInvite", 1145 Self::CollaborationAccept => "collaborationAccept", 1146 Self::NewEntry => "newEntry", 1147 Self::EntryUpdate => "entryUpdate", 1148 Self::Mention => "mention", 1149 Self::Tag => "tag", 1150 Self::Comment => "comment", 1151 Self::Other(s) => s.as_ref(), 1152 } 1153 } 1154} 1155 1156impl<'a> From<&'a str> for NotificationReason<'a> { 1157 fn from(s: &'a str) -> Self { 1158 match s { 1159 "like" => Self::Like, 1160 "bookmark" => Self::Bookmark, 1161 "follow" => Self::Follow, 1162 "followAccept" => Self::FollowAccept, 1163 "subscribe" => Self::Subscribe, 1164 "subscribeAccept" => Self::SubscribeAccept, 1165 "collaborationInvite" => Self::CollaborationInvite, 1166 "collaborationAccept" => Self::CollaborationAccept, 1167 "newEntry" => Self::NewEntry, 1168 "entryUpdate" => Self::EntryUpdate, 1169 "mention" => Self::Mention, 1170 "tag" => Self::Tag, 1171 "comment" => Self::Comment, 1172 _ => Self::Other(jacquard_common::CowStr::from(s)), 1173 } 1174 } 1175} 1176 1177impl<'a> From<String> for NotificationReason<'a> { 1178 fn from(s: String) -> Self { 1179 match s.as_str() { 1180 "like" => Self::Like, 1181 "bookmark" => Self::Bookmark, 1182 "follow" => Self::Follow, 1183 "followAccept" => Self::FollowAccept, 1184 "subscribe" => Self::Subscribe, 1185 "subscribeAccept" => Self::SubscribeAccept, 1186 "collaborationInvite" => Self::CollaborationInvite, 1187 "collaborationAccept" => Self::CollaborationAccept, 1188 "newEntry" => Self::NewEntry, 1189 "entryUpdate" => Self::EntryUpdate, 1190 "mention" => Self::Mention, 1191 "tag" => Self::Tag, 1192 "comment" => Self::Comment, 1193 _ => Self::Other(jacquard_common::CowStr::from(s)), 1194 } 1195 } 1196} 1197 1198impl<'a> AsRef<str> for NotificationReason<'a> { 1199 fn as_ref(&self) -> &str { 1200 self.as_str() 1201 } 1202} 1203 1204impl<'a> core::fmt::Display for NotificationReason<'a> { 1205 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 1206 write!(f, "{}", self.as_str()) 1207 } 1208} 1209 1210impl<'a> serde::Serialize for NotificationReason<'a> { 1211 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> 1212 where 1213 S: serde::Serializer, 1214 { 1215 serializer.serialize_str(self.as_str()) 1216 } 1217} 1218 1219impl<'de, 'a> serde::Deserialize<'de> for NotificationReason<'a> 1220where 1221 'de: 'a, 1222{ 1223 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> 1224 where 1225 D: serde::Deserializer<'de>, 1226 { 1227 let s = <&'de str>::deserialize(deserializer)?; 1228 Ok(Self::from(s)) 1229 } 1230} 1231 1232impl jacquard_common::IntoStatic for NotificationReason<'_> { 1233 type Output = NotificationReason<'static>; 1234 fn into_static(self) -> Self::Output { 1235 match self { 1236 NotificationReason::Like => NotificationReason::Like, 1237 NotificationReason::Bookmark => NotificationReason::Bookmark, 1238 NotificationReason::Follow => NotificationReason::Follow, 1239 NotificationReason::FollowAccept => NotificationReason::FollowAccept, 1240 NotificationReason::Subscribe => NotificationReason::Subscribe, 1241 NotificationReason::SubscribeAccept => NotificationReason::SubscribeAccept, 1242 NotificationReason::CollaborationInvite => { 1243 NotificationReason::CollaborationInvite 1244 } 1245 NotificationReason::CollaborationAccept => { 1246 NotificationReason::CollaborationAccept 1247 } 1248 NotificationReason::NewEntry => NotificationReason::NewEntry, 1249 NotificationReason::EntryUpdate => NotificationReason::EntryUpdate, 1250 NotificationReason::Mention => NotificationReason::Mention, 1251 NotificationReason::Tag => NotificationReason::Tag, 1252 NotificationReason::Comment => NotificationReason::Comment, 1253 NotificationReason::Other(v) => NotificationReason::Other(v.into_static()), 1254 } 1255 } 1256} 1257 1258/// New content from a notebook subscription. 1259#[jacquard_derive::lexicon] 1260#[derive( 1261 serde::Serialize, 1262 serde::Deserialize, 1263 Debug, 1264 Clone, 1265 PartialEq, 1266 Eq, 1267 jacquard_derive::IntoStatic 1268)] 1269#[serde(rename_all = "camelCase")] 1270pub struct SubscriptionUpdateView<'a> { 1271 /// New entries since last check. 1272 #[serde(borrow)] 1273 pub new_entries: Vec<crate::sh_weaver::notebook::EntryView<'a>>, 1274 #[serde(borrow)] 1275 pub notebook: crate::sh_weaver::notebook::NotebookView<'a>, 1276 pub updated_at: jacquard_common::types::string::Datetime, 1277 /// Entries that were updated. 1278 #[serde(skip_serializing_if = "std::option::Option::is_none")] 1279 #[serde(borrow)] 1280 pub updated_entries: std::option::Option< 1281 Vec<crate::sh_weaver::notebook::EntryView<'a>>, 1282 >, 1283} 1284 1285pub mod subscription_update_view_state { 1286 1287 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 1288 #[allow(unused)] 1289 use ::core::marker::PhantomData; 1290 mod sealed { 1291 pub trait Sealed {} 1292 } 1293 /// State trait tracking which required fields have been set 1294 pub trait State: sealed::Sealed { 1295 type NewEntries; 1296 type Notebook; 1297 type UpdatedAt; 1298 } 1299 /// Empty state - all required fields are unset 1300 pub struct Empty(()); 1301 impl sealed::Sealed for Empty {} 1302 impl State for Empty { 1303 type NewEntries = Unset; 1304 type Notebook = Unset; 1305 type UpdatedAt = Unset; 1306 } 1307 ///State transition - sets the `new_entries` field to Set 1308 pub struct SetNewEntries<S: State = Empty>(PhantomData<fn() -> S>); 1309 impl<S: State> sealed::Sealed for SetNewEntries<S> {} 1310 impl<S: State> State for SetNewEntries<S> { 1311 type NewEntries = Set<members::new_entries>; 1312 type Notebook = S::Notebook; 1313 type UpdatedAt = S::UpdatedAt; 1314 } 1315 ///State transition - sets the `notebook` field to Set 1316 pub struct SetNotebook<S: State = Empty>(PhantomData<fn() -> S>); 1317 impl<S: State> sealed::Sealed for SetNotebook<S> {} 1318 impl<S: State> State for SetNotebook<S> { 1319 type NewEntries = S::NewEntries; 1320 type Notebook = Set<members::notebook>; 1321 type UpdatedAt = S::UpdatedAt; 1322 } 1323 ///State transition - sets the `updated_at` field to Set 1324 pub struct SetUpdatedAt<S: State = Empty>(PhantomData<fn() -> S>); 1325 impl<S: State> sealed::Sealed for SetUpdatedAt<S> {} 1326 impl<S: State> State for SetUpdatedAt<S> { 1327 type NewEntries = S::NewEntries; 1328 type Notebook = S::Notebook; 1329 type UpdatedAt = Set<members::updated_at>; 1330 } 1331 /// Marker types for field names 1332 #[allow(non_camel_case_types)] 1333 pub mod members { 1334 ///Marker type for the `new_entries` field 1335 pub struct new_entries(()); 1336 ///Marker type for the `notebook` field 1337 pub struct notebook(()); 1338 ///Marker type for the `updated_at` field 1339 pub struct updated_at(()); 1340 } 1341} 1342 1343/// Builder for constructing an instance of this type 1344pub struct SubscriptionUpdateViewBuilder<'a, S: subscription_update_view_state::State> { 1345 _phantom_state: ::core::marker::PhantomData<fn() -> S>, 1346 __unsafe_private_named: ( 1347 ::core::option::Option<Vec<crate::sh_weaver::notebook::EntryView<'a>>>, 1348 ::core::option::Option<crate::sh_weaver::notebook::NotebookView<'a>>, 1349 ::core::option::Option<jacquard_common::types::string::Datetime>, 1350 ::core::option::Option<Vec<crate::sh_weaver::notebook::EntryView<'a>>>, 1351 ), 1352 _phantom: ::core::marker::PhantomData<&'a ()>, 1353} 1354 1355impl<'a> SubscriptionUpdateView<'a> { 1356 /// Create a new builder for this type 1357 pub fn new() -> SubscriptionUpdateViewBuilder< 1358 'a, 1359 subscription_update_view_state::Empty, 1360 > { 1361 SubscriptionUpdateViewBuilder::new() 1362 } 1363} 1364 1365impl<'a> SubscriptionUpdateViewBuilder<'a, subscription_update_view_state::Empty> { 1366 /// Create a new builder with all fields unset 1367 pub fn new() -> Self { 1368 SubscriptionUpdateViewBuilder { 1369 _phantom_state: ::core::marker::PhantomData, 1370 __unsafe_private_named: (None, None, None, None), 1371 _phantom: ::core::marker::PhantomData, 1372 } 1373 } 1374} 1375 1376impl<'a, S> SubscriptionUpdateViewBuilder<'a, S> 1377where 1378 S: subscription_update_view_state::State, 1379 S::NewEntries: subscription_update_view_state::IsUnset, 1380{ 1381 /// Set the `newEntries` field (required) 1382 pub fn new_entries( 1383 mut self, 1384 value: impl Into<Vec<crate::sh_weaver::notebook::EntryView<'a>>>, 1385 ) -> SubscriptionUpdateViewBuilder< 1386 'a, 1387 subscription_update_view_state::SetNewEntries<S>, 1388 > { 1389 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); 1390 SubscriptionUpdateViewBuilder { 1391 _phantom_state: ::core::marker::PhantomData, 1392 __unsafe_private_named: self.__unsafe_private_named, 1393 _phantom: ::core::marker::PhantomData, 1394 } 1395 } 1396} 1397 1398impl<'a, S> SubscriptionUpdateViewBuilder<'a, S> 1399where 1400 S: subscription_update_view_state::State, 1401 S::Notebook: subscription_update_view_state::IsUnset, 1402{ 1403 /// Set the `notebook` field (required) 1404 pub fn notebook( 1405 mut self, 1406 value: impl Into<crate::sh_weaver::notebook::NotebookView<'a>>, 1407 ) -> SubscriptionUpdateViewBuilder< 1408 'a, 1409 subscription_update_view_state::SetNotebook<S>, 1410 > { 1411 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); 1412 SubscriptionUpdateViewBuilder { 1413 _phantom_state: ::core::marker::PhantomData, 1414 __unsafe_private_named: self.__unsafe_private_named, 1415 _phantom: ::core::marker::PhantomData, 1416 } 1417 } 1418} 1419 1420impl<'a, S> SubscriptionUpdateViewBuilder<'a, S> 1421where 1422 S: subscription_update_view_state::State, 1423 S::UpdatedAt: subscription_update_view_state::IsUnset, 1424{ 1425 /// Set the `updatedAt` field (required) 1426 pub fn updated_at( 1427 mut self, 1428 value: impl Into<jacquard_common::types::string::Datetime>, 1429 ) -> SubscriptionUpdateViewBuilder< 1430 'a, 1431 subscription_update_view_state::SetUpdatedAt<S>, 1432 > { 1433 self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into()); 1434 SubscriptionUpdateViewBuilder { 1435 _phantom_state: ::core::marker::PhantomData, 1436 __unsafe_private_named: self.__unsafe_private_named, 1437 _phantom: ::core::marker::PhantomData, 1438 } 1439 } 1440} 1441 1442impl<'a, S: subscription_update_view_state::State> SubscriptionUpdateViewBuilder<'a, S> { 1443 /// Set the `updatedEntries` field (optional) 1444 pub fn updated_entries( 1445 mut self, 1446 value: impl Into<Option<Vec<crate::sh_weaver::notebook::EntryView<'a>>>>, 1447 ) -> Self { 1448 self.__unsafe_private_named.3 = value.into(); 1449 self 1450 } 1451 /// Set the `updatedEntries` field to an Option value (optional) 1452 pub fn maybe_updated_entries( 1453 mut self, 1454 value: Option<Vec<crate::sh_weaver::notebook::EntryView<'a>>>, 1455 ) -> Self { 1456 self.__unsafe_private_named.3 = value; 1457 self 1458 } 1459} 1460 1461impl<'a, S> SubscriptionUpdateViewBuilder<'a, S> 1462where 1463 S: subscription_update_view_state::State, 1464 S::NewEntries: subscription_update_view_state::IsSet, 1465 S::Notebook: subscription_update_view_state::IsSet, 1466 S::UpdatedAt: subscription_update_view_state::IsSet, 1467{ 1468 /// Build the final struct 1469 pub fn build(self) -> SubscriptionUpdateView<'a> { 1470 SubscriptionUpdateView { 1471 new_entries: self.__unsafe_private_named.0.unwrap(), 1472 notebook: self.__unsafe_private_named.1.unwrap(), 1473 updated_at: self.__unsafe_private_named.2.unwrap(), 1474 updated_entries: self.__unsafe_private_named.3, 1475 extra_data: Default::default(), 1476 } 1477 } 1478 /// Build the final struct with custom extra_data 1479 pub fn build_with_data( 1480 self, 1481 extra_data: std::collections::BTreeMap< 1482 jacquard_common::smol_str::SmolStr, 1483 jacquard_common::types::value::Data<'a>, 1484 >, 1485 ) -> SubscriptionUpdateView<'a> { 1486 SubscriptionUpdateView { 1487 new_entries: self.__unsafe_private_named.0.unwrap(), 1488 notebook: self.__unsafe_private_named.1.unwrap(), 1489 updated_at: self.__unsafe_private_named.2.unwrap(), 1490 updated_entries: self.__unsafe_private_named.3, 1491 extra_data: Some(extra_data), 1492 } 1493 } 1494} 1495 1496impl<'a> ::jacquard_lexicon::schema::LexiconSchema for SubscriptionUpdateView<'a> { 1497 fn nsid() -> &'static str { 1498 "sh.weaver.notification.defs" 1499 } 1500 fn def_name() -> &'static str { 1501 "subscriptionUpdateView" 1502 } 1503 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { 1504 lexicon_doc_sh_weaver_notification_defs() 1505 } 1506 fn validate( 1507 &self, 1508 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { 1509 Ok(()) 1510 } 1511}