// @generated by jacquard-lexicon. DO NOT EDIT. // // Lexicon: sh.weaver.notification.defs // // This file was automatically generated from Lexicon schemas. // Any manual changes will be overwritten on the next regeneration. pub mod get_subscription_updates; pub mod get_unread_count; pub mod list_notifications; pub mod update_seen; /// A notification for a user. #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct Notification<'a> { #[serde(borrow)] pub author: crate::sh_weaver::actor::ProfileViewBasic<'a>, #[serde(borrow)] pub cid: jacquard_common::types::string::Cid<'a>, pub indexed_at: jacquard_common::types::string::Datetime, pub is_read: bool, #[serde(borrow)] pub reason: crate::sh_weaver::notification::NotificationReason<'a>, /// The subject of the notification (entry, notebook, etc). #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub reason_subject: std::option::Option>, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub record: std::option::Option>, #[serde(borrow)] pub uri: jacquard_common::types::string::AtUri<'a>, } pub mod notification_state { pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; #[allow(unused)] use ::core::marker::PhantomData; mod sealed { pub trait Sealed {} } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { type Cid; type IndexedAt; type IsRead; type Author; type Uri; type Reason; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Cid = Unset; type IndexedAt = Unset; type IsRead = Unset; type Author = Unset; type Uri = Unset; type Reason = Unset; } ///State transition - sets the `cid` field to Set pub struct SetCid(PhantomData S>); impl sealed::Sealed for SetCid {} impl State for SetCid { type Cid = Set; type IndexedAt = S::IndexedAt; type IsRead = S::IsRead; type Author = S::Author; type Uri = S::Uri; type Reason = S::Reason; } ///State transition - sets the `indexed_at` field to Set pub struct SetIndexedAt(PhantomData S>); impl sealed::Sealed for SetIndexedAt {} impl State for SetIndexedAt { type Cid = S::Cid; type IndexedAt = Set; type IsRead = S::IsRead; type Author = S::Author; type Uri = S::Uri; type Reason = S::Reason; } ///State transition - sets the `is_read` field to Set pub struct SetIsRead(PhantomData S>); impl sealed::Sealed for SetIsRead {} impl State for SetIsRead { type Cid = S::Cid; type IndexedAt = S::IndexedAt; type IsRead = Set; type Author = S::Author; type Uri = S::Uri; type Reason = S::Reason; } ///State transition - sets the `author` field to Set pub struct SetAuthor(PhantomData S>); impl sealed::Sealed for SetAuthor {} impl State for SetAuthor { type Cid = S::Cid; type IndexedAt = S::IndexedAt; type IsRead = S::IsRead; type Author = Set; type Uri = S::Uri; type Reason = S::Reason; } ///State transition - sets the `uri` field to Set pub struct SetUri(PhantomData S>); impl sealed::Sealed for SetUri {} impl State for SetUri { type Cid = S::Cid; type IndexedAt = S::IndexedAt; type IsRead = S::IsRead; type Author = S::Author; type Uri = Set; type Reason = S::Reason; } ///State transition - sets the `reason` field to Set pub struct SetReason(PhantomData S>); impl sealed::Sealed for SetReason {} impl State for SetReason { type Cid = S::Cid; type IndexedAt = S::IndexedAt; type IsRead = S::IsRead; type Author = S::Author; type Uri = S::Uri; type Reason = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `cid` field pub struct cid(()); ///Marker type for the `indexed_at` field pub struct indexed_at(()); ///Marker type for the `is_read` field pub struct is_read(()); ///Marker type for the `author` field pub struct author(()); ///Marker type for the `uri` field pub struct uri(()); ///Marker type for the `reason` field pub struct reason(()); } } /// Builder for constructing an instance of this type pub struct NotificationBuilder<'a, S: notification_state::State> { _phantom_state: ::core::marker::PhantomData S>, __unsafe_private_named: ( ::core::option::Option>, ::core::option::Option>, ::core::option::Option, ::core::option::Option, ::core::option::Option>, ::core::option::Option>, ::core::option::Option>, ::core::option::Option>, ), _phantom: ::core::marker::PhantomData<&'a ()>, } impl<'a> Notification<'a> { /// Create a new builder for this type pub fn new() -> NotificationBuilder<'a, notification_state::Empty> { NotificationBuilder::new() } } impl<'a> NotificationBuilder<'a, notification_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { NotificationBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: (None, None, None, None, None, None, None, None), _phantom: ::core::marker::PhantomData, } } } impl<'a, S> NotificationBuilder<'a, S> where S: notification_state::State, S::Author: notification_state::IsUnset, { /// Set the `author` field (required) pub fn author( mut self, value: impl Into>, ) -> NotificationBuilder<'a, notification_state::SetAuthor> { self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); NotificationBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> NotificationBuilder<'a, S> where S: notification_state::State, S::Cid: notification_state::IsUnset, { /// Set the `cid` field (required) pub fn cid( mut self, value: impl Into>, ) -> NotificationBuilder<'a, notification_state::SetCid> { self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); NotificationBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> NotificationBuilder<'a, S> where S: notification_state::State, S::IndexedAt: notification_state::IsUnset, { /// Set the `indexedAt` field (required) pub fn indexed_at( mut self, value: impl Into, ) -> NotificationBuilder<'a, notification_state::SetIndexedAt> { self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into()); NotificationBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> NotificationBuilder<'a, S> where S: notification_state::State, S::IsRead: notification_state::IsUnset, { /// Set the `isRead` field (required) pub fn is_read( mut self, value: impl Into, ) -> NotificationBuilder<'a, notification_state::SetIsRead> { self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into()); NotificationBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> NotificationBuilder<'a, S> where S: notification_state::State, S::Reason: notification_state::IsUnset, { /// Set the `reason` field (required) pub fn reason( mut self, value: impl Into>, ) -> NotificationBuilder<'a, notification_state::SetReason> { self.__unsafe_private_named.4 = ::core::option::Option::Some(value.into()); NotificationBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S: notification_state::State> NotificationBuilder<'a, S> { /// Set the `reasonSubject` field (optional) pub fn reason_subject( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.5 = value.into(); self } /// Set the `reasonSubject` field to an Option value (optional) pub fn maybe_reason_subject( mut self, value: Option>, ) -> Self { self.__unsafe_private_named.5 = value; self } } impl<'a, S: notification_state::State> NotificationBuilder<'a, S> { /// Set the `record` field (optional) pub fn record( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.6 = value.into(); self } /// Set the `record` field to an Option value (optional) pub fn maybe_record( mut self, value: Option>, ) -> Self { self.__unsafe_private_named.6 = value; self } } impl<'a, S> NotificationBuilder<'a, S> where S: notification_state::State, S::Uri: notification_state::IsUnset, { /// Set the `uri` field (required) pub fn uri( mut self, value: impl Into>, ) -> NotificationBuilder<'a, notification_state::SetUri> { self.__unsafe_private_named.7 = ::core::option::Option::Some(value.into()); NotificationBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> NotificationBuilder<'a, S> where S: notification_state::State, S::Cid: notification_state::IsSet, S::IndexedAt: notification_state::IsSet, S::IsRead: notification_state::IsSet, S::Author: notification_state::IsSet, S::Uri: notification_state::IsSet, S::Reason: notification_state::IsSet, { /// Build the final struct pub fn build(self) -> Notification<'a> { Notification { author: self.__unsafe_private_named.0.unwrap(), cid: self.__unsafe_private_named.1.unwrap(), indexed_at: self.__unsafe_private_named.2.unwrap(), is_read: self.__unsafe_private_named.3.unwrap(), reason: self.__unsafe_private_named.4.unwrap(), reason_subject: self.__unsafe_private_named.5, record: self.__unsafe_private_named.6, uri: self.__unsafe_private_named.7.unwrap(), extra_data: Default::default(), } } /// Build the final struct with custom extra_data pub fn build_with_data( self, extra_data: std::collections::BTreeMap< jacquard_common::smol_str::SmolStr, jacquard_common::types::value::Data<'a>, >, ) -> Notification<'a> { Notification { author: self.__unsafe_private_named.0.unwrap(), cid: self.__unsafe_private_named.1.unwrap(), indexed_at: self.__unsafe_private_named.2.unwrap(), is_read: self.__unsafe_private_named.3.unwrap(), reason: self.__unsafe_private_named.4.unwrap(), reason_subject: self.__unsafe_private_named.5, record: self.__unsafe_private_named.6, uri: self.__unsafe_private_named.7.unwrap(), extra_data: Some(extra_data), } } } fn lexicon_doc_sh_weaver_notification_defs() -> ::jacquard_lexicon::lexicon::LexiconDoc< 'static, > { ::jacquard_lexicon::lexicon::LexiconDoc { lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, id: ::jacquard_common::CowStr::new_static("sh.weaver.notification.defs"), revision: None, description: None, defs: { let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("notification"), ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { description: Some( ::jacquard_common::CowStr::new_static( "A notification for a user.", ), ), required: Some( vec![ ::jacquard_common::smol_str::SmolStr::new_static("uri"), ::jacquard_common::smol_str::SmolStr::new_static("cid"), ::jacquard_common::smol_str::SmolStr::new_static("author"), ::jacquard_common::smol_str::SmolStr::new_static("reason"), ::jacquard_common::smol_str::SmolStr::new_static("isRead"), ::jacquard_common::smol_str::SmolStr::new_static("indexedAt") ], ), nullable: None, properties: { #[allow(unused_mut)] let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("author"), ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { description: None, r#ref: ::jacquard_common::CowStr::new_static( "sh.weaver.actor.defs#profileViewBasic", ), }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("cid"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, format: Some( ::jacquard_lexicon::lexicon::LexStringFormat::Cid, ), default: None, min_length: None, max_length: None, min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "indexedAt", ), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, format: Some( ::jacquard_lexicon::lexicon::LexStringFormat::Datetime, ), default: None, min_length: None, max_length: None, min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("isRead"), ::jacquard_lexicon::lexicon::LexObjectProperty::Boolean(::jacquard_lexicon::lexicon::LexBoolean { description: None, default: None, r#const: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("reason"), ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { description: None, r#ref: ::jacquard_common::CowStr::new_static( "#notificationReason", ), }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "reasonSubject", ), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: Some( ::jacquard_common::CowStr::new_static( "The subject of the notification (entry, notebook, etc).", ), ), format: Some( ::jacquard_lexicon::lexicon::LexStringFormat::AtUri, ), default: None, min_length: None, max_length: None, min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("record"), ::jacquard_lexicon::lexicon::LexObjectProperty::Unknown(::jacquard_lexicon::lexicon::LexUnknown { description: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("uri"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, format: Some( ::jacquard_lexicon::lexicon::LexStringFormat::AtUri, ), default: None, min_length: None, max_length: None, min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map }, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("notificationGroup"), ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { description: Some( ::jacquard_common::CowStr::new_static( "Grouped notifications (e.g., '5 people liked your entry').", ), ), required: Some( vec![ ::jacquard_common::smol_str::SmolStr::new_static("reason"), ::jacquard_common::smol_str::SmolStr::new_static("subject"), ::jacquard_common::smol_str::SmolStr::new_static("count"), ::jacquard_common::smol_str::SmolStr::new_static("actors"), ::jacquard_common::smol_str::SmolStr::new_static("mostRecentAt") ], ), nullable: None, properties: { #[allow(unused_mut)] let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("actors"), ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray { description: Some( ::jacquard_common::CowStr::new_static( "Most recent actors (up to 5).", ), ), items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef { description: None, r#ref: ::jacquard_common::CowStr::new_static( "sh.weaver.actor.defs#profileViewBasic", ), }), min_length: None, max_length: Some(5usize), }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("count"), ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger { description: None, default: None, minimum: None, maximum: None, r#enum: None, r#const: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("isRead"), ::jacquard_lexicon::lexicon::LexObjectProperty::Boolean(::jacquard_lexicon::lexicon::LexBoolean { description: None, default: None, r#const: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "mostRecentAt", ), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, format: Some( ::jacquard_lexicon::lexicon::LexStringFormat::Datetime, ), default: None, min_length: None, max_length: None, min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("reason"), ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { description: None, r#ref: ::jacquard_common::CowStr::new_static( "#notificationReason", ), }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("subject"), ::jacquard_lexicon::lexicon::LexObjectProperty::Union(::jacquard_lexicon::lexicon::LexRefUnion { description: None, refs: vec![ ::jacquard_common::CowStr::new_static("sh.weaver.notebook.defs#notebookView"), ::jacquard_common::CowStr::new_static("sh.weaver.notebook.defs#entryView") ], closed: None, }), ); map }, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("notificationReason"), ::jacquard_lexicon::lexicon::LexUserType::String(::jacquard_lexicon::lexicon::LexString { description: Some( ::jacquard_common::CowStr::new_static( "Why this notification was generated.", ), ), format: None, default: None, min_length: None, max_length: None, min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "subscriptionUpdateView", ), ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { description: Some( ::jacquard_common::CowStr::new_static( "New content from a notebook subscription.", ), ), required: Some( vec![ ::jacquard_common::smol_str::SmolStr::new_static("notebook"), ::jacquard_common::smol_str::SmolStr::new_static("newEntries"), ::jacquard_common::smol_str::SmolStr::new_static("updatedAt") ], ), nullable: None, properties: { #[allow(unused_mut)] let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "newEntries", ), ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray { description: Some( ::jacquard_common::CowStr::new_static( "New entries since last check.", ), ), items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef { description: None, r#ref: ::jacquard_common::CowStr::new_static( "sh.weaver.notebook.defs#entryView", ), }), min_length: None, max_length: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("notebook"), ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { description: None, r#ref: ::jacquard_common::CowStr::new_static( "sh.weaver.notebook.defs#notebookView", ), }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "updatedAt", ), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, format: Some( ::jacquard_lexicon::lexicon::LexStringFormat::Datetime, ), default: None, min_length: None, max_length: None, min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "updatedEntries", ), ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray { description: Some( ::jacquard_common::CowStr::new_static( "Entries that were updated.", ), ), items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef { description: None, r#ref: ::jacquard_common::CowStr::new_static( "sh.weaver.notebook.defs#entryView", ), }), min_length: None, max_length: None, }), ); map }, }), ); map }, } } impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Notification<'a> { fn nsid() -> &'static str { "sh.weaver.notification.defs" } fn def_name() -> &'static str { "notification" } fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { lexicon_doc_sh_weaver_notification_defs() } fn validate( &self, ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { Ok(()) } } /// Grouped notifications (e.g., '5 people liked your entry'). #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct NotificationGroup<'a> { /// Most recent actors (up to 5). #[serde(borrow)] pub actors: Vec>, pub count: i64, #[serde(skip_serializing_if = "std::option::Option::is_none")] pub is_read: std::option::Option, pub most_recent_at: jacquard_common::types::string::Datetime, #[serde(borrow)] pub reason: crate::sh_weaver::notification::NotificationReason<'a>, #[serde(borrow)] pub subject: NotificationGroupSubject<'a>, } pub mod notification_group_state { pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; #[allow(unused)] use ::core::marker::PhantomData; mod sealed { pub trait Sealed {} } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { type Count; type Reason; type Actors; type Subject; type MostRecentAt; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Count = Unset; type Reason = Unset; type Actors = Unset; type Subject = Unset; type MostRecentAt = Unset; } ///State transition - sets the `count` field to Set pub struct SetCount(PhantomData S>); impl sealed::Sealed for SetCount {} impl State for SetCount { type Count = Set; type Reason = S::Reason; type Actors = S::Actors; type Subject = S::Subject; type MostRecentAt = S::MostRecentAt; } ///State transition - sets the `reason` field to Set pub struct SetReason(PhantomData S>); impl sealed::Sealed for SetReason {} impl State for SetReason { type Count = S::Count; type Reason = Set; type Actors = S::Actors; type Subject = S::Subject; type MostRecentAt = S::MostRecentAt; } ///State transition - sets the `actors` field to Set pub struct SetActors(PhantomData S>); impl sealed::Sealed for SetActors {} impl State for SetActors { type Count = S::Count; type Reason = S::Reason; type Actors = Set; type Subject = S::Subject; type MostRecentAt = S::MostRecentAt; } ///State transition - sets the `subject` field to Set pub struct SetSubject(PhantomData S>); impl sealed::Sealed for SetSubject {} impl State for SetSubject { type Count = S::Count; type Reason = S::Reason; type Actors = S::Actors; type Subject = Set; type MostRecentAt = S::MostRecentAt; } ///State transition - sets the `most_recent_at` field to Set pub struct SetMostRecentAt(PhantomData S>); impl sealed::Sealed for SetMostRecentAt {} impl State for SetMostRecentAt { type Count = S::Count; type Reason = S::Reason; type Actors = S::Actors; type Subject = S::Subject; type MostRecentAt = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `count` field pub struct count(()); ///Marker type for the `reason` field pub struct reason(()); ///Marker type for the `actors` field pub struct actors(()); ///Marker type for the `subject` field pub struct subject(()); ///Marker type for the `most_recent_at` field pub struct most_recent_at(()); } } /// Builder for constructing an instance of this type pub struct NotificationGroupBuilder<'a, S: notification_group_state::State> { _phantom_state: ::core::marker::PhantomData S>, __unsafe_private_named: ( ::core::option::Option>>, ::core::option::Option, ::core::option::Option, ::core::option::Option, ::core::option::Option>, ::core::option::Option>, ), _phantom: ::core::marker::PhantomData<&'a ()>, } impl<'a> NotificationGroup<'a> { /// Create a new builder for this type pub fn new() -> NotificationGroupBuilder<'a, notification_group_state::Empty> { NotificationGroupBuilder::new() } } impl<'a> NotificationGroupBuilder<'a, notification_group_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { NotificationGroupBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: (None, None, None, None, None, None), _phantom: ::core::marker::PhantomData, } } } impl<'a, S> NotificationGroupBuilder<'a, S> where S: notification_group_state::State, S::Actors: notification_group_state::IsUnset, { /// Set the `actors` field (required) pub fn actors( mut self, value: impl Into>>, ) -> NotificationGroupBuilder<'a, notification_group_state::SetActors> { self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); NotificationGroupBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> NotificationGroupBuilder<'a, S> where S: notification_group_state::State, S::Count: notification_group_state::IsUnset, { /// Set the `count` field (required) pub fn count( mut self, value: impl Into, ) -> NotificationGroupBuilder<'a, notification_group_state::SetCount> { self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); NotificationGroupBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S: notification_group_state::State> NotificationGroupBuilder<'a, S> { /// Set the `isRead` field (optional) pub fn is_read(mut self, value: impl Into>) -> Self { self.__unsafe_private_named.2 = value.into(); self } /// Set the `isRead` field to an Option value (optional) pub fn maybe_is_read(mut self, value: Option) -> Self { self.__unsafe_private_named.2 = value; self } } impl<'a, S> NotificationGroupBuilder<'a, S> where S: notification_group_state::State, S::MostRecentAt: notification_group_state::IsUnset, { /// Set the `mostRecentAt` field (required) pub fn most_recent_at( mut self, value: impl Into, ) -> NotificationGroupBuilder<'a, notification_group_state::SetMostRecentAt> { self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into()); NotificationGroupBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> NotificationGroupBuilder<'a, S> where S: notification_group_state::State, S::Reason: notification_group_state::IsUnset, { /// Set the `reason` field (required) pub fn reason( mut self, value: impl Into>, ) -> NotificationGroupBuilder<'a, notification_group_state::SetReason> { self.__unsafe_private_named.4 = ::core::option::Option::Some(value.into()); NotificationGroupBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> NotificationGroupBuilder<'a, S> where S: notification_group_state::State, S::Subject: notification_group_state::IsUnset, { /// Set the `subject` field (required) pub fn subject( mut self, value: impl Into>, ) -> NotificationGroupBuilder<'a, notification_group_state::SetSubject> { self.__unsafe_private_named.5 = ::core::option::Option::Some(value.into()); NotificationGroupBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> NotificationGroupBuilder<'a, S> where S: notification_group_state::State, S::Count: notification_group_state::IsSet, S::Reason: notification_group_state::IsSet, S::Actors: notification_group_state::IsSet, S::Subject: notification_group_state::IsSet, S::MostRecentAt: notification_group_state::IsSet, { /// Build the final struct pub fn build(self) -> NotificationGroup<'a> { NotificationGroup { actors: self.__unsafe_private_named.0.unwrap(), count: self.__unsafe_private_named.1.unwrap(), is_read: self.__unsafe_private_named.2, most_recent_at: self.__unsafe_private_named.3.unwrap(), reason: self.__unsafe_private_named.4.unwrap(), subject: self.__unsafe_private_named.5.unwrap(), extra_data: Default::default(), } } /// Build the final struct with custom extra_data pub fn build_with_data( self, extra_data: std::collections::BTreeMap< jacquard_common::smol_str::SmolStr, jacquard_common::types::value::Data<'a>, >, ) -> NotificationGroup<'a> { NotificationGroup { actors: self.__unsafe_private_named.0.unwrap(), count: self.__unsafe_private_named.1.unwrap(), is_read: self.__unsafe_private_named.2, most_recent_at: self.__unsafe_private_named.3.unwrap(), reason: self.__unsafe_private_named.4.unwrap(), subject: self.__unsafe_private_named.5.unwrap(), extra_data: Some(extra_data), } } } #[jacquard_derive::open_union] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(tag = "$type")] #[serde(bound(deserialize = "'de: 'a"))] pub enum NotificationGroupSubject<'a> { #[serde(rename = "sh.weaver.notebook.defs#notebookView")] NotebookView(Box>), #[serde(rename = "sh.weaver.notebook.defs#entryView")] EntryView(Box>), } impl<'a> ::jacquard_lexicon::schema::LexiconSchema for NotificationGroup<'a> { fn nsid() -> &'static str { "sh.weaver.notification.defs" } fn def_name() -> &'static str { "notificationGroup" } fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { lexicon_doc_sh_weaver_notification_defs() } fn validate( &self, ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { { let value = &self.actors; #[allow(unused_comparisons)] if value.len() > 5usize { return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength { path: ::jacquard_lexicon::validation::ValidationPath::from_field( "actors", ), max: 5usize, actual: value.len(), }); } } Ok(()) } } /// Why this notification was generated. #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum NotificationReason<'a> { Like, Bookmark, Follow, FollowAccept, Subscribe, SubscribeAccept, CollaborationInvite, CollaborationAccept, NewEntry, EntryUpdate, Mention, Tag, Comment, Other(jacquard_common::CowStr<'a>), } impl<'a> NotificationReason<'a> { pub fn as_str(&self) -> &str { match self { Self::Like => "like", Self::Bookmark => "bookmark", Self::Follow => "follow", Self::FollowAccept => "followAccept", Self::Subscribe => "subscribe", Self::SubscribeAccept => "subscribeAccept", Self::CollaborationInvite => "collaborationInvite", Self::CollaborationAccept => "collaborationAccept", Self::NewEntry => "newEntry", Self::EntryUpdate => "entryUpdate", Self::Mention => "mention", Self::Tag => "tag", Self::Comment => "comment", Self::Other(s) => s.as_ref(), } } } impl<'a> From<&'a str> for NotificationReason<'a> { fn from(s: &'a str) -> Self { match s { "like" => Self::Like, "bookmark" => Self::Bookmark, "follow" => Self::Follow, "followAccept" => Self::FollowAccept, "subscribe" => Self::Subscribe, "subscribeAccept" => Self::SubscribeAccept, "collaborationInvite" => Self::CollaborationInvite, "collaborationAccept" => Self::CollaborationAccept, "newEntry" => Self::NewEntry, "entryUpdate" => Self::EntryUpdate, "mention" => Self::Mention, "tag" => Self::Tag, "comment" => Self::Comment, _ => Self::Other(jacquard_common::CowStr::from(s)), } } } impl<'a> From for NotificationReason<'a> { fn from(s: String) -> Self { match s.as_str() { "like" => Self::Like, "bookmark" => Self::Bookmark, "follow" => Self::Follow, "followAccept" => Self::FollowAccept, "subscribe" => Self::Subscribe, "subscribeAccept" => Self::SubscribeAccept, "collaborationInvite" => Self::CollaborationInvite, "collaborationAccept" => Self::CollaborationAccept, "newEntry" => Self::NewEntry, "entryUpdate" => Self::EntryUpdate, "mention" => Self::Mention, "tag" => Self::Tag, "comment" => Self::Comment, _ => Self::Other(jacquard_common::CowStr::from(s)), } } } impl<'a> AsRef for NotificationReason<'a> { fn as_ref(&self) -> &str { self.as_str() } } impl<'a> core::fmt::Display for NotificationReason<'a> { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!(f, "{}", self.as_str()) } } impl<'a> serde::Serialize for NotificationReason<'a> { fn serialize(&self, serializer: S) -> Result where S: serde::Serializer, { serializer.serialize_str(self.as_str()) } } impl<'de, 'a> serde::Deserialize<'de> for NotificationReason<'a> where 'de: 'a, { fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'de>, { let s = <&'de str>::deserialize(deserializer)?; Ok(Self::from(s)) } } impl jacquard_common::IntoStatic for NotificationReason<'_> { type Output = NotificationReason<'static>; fn into_static(self) -> Self::Output { match self { NotificationReason::Like => NotificationReason::Like, NotificationReason::Bookmark => NotificationReason::Bookmark, NotificationReason::Follow => NotificationReason::Follow, NotificationReason::FollowAccept => NotificationReason::FollowAccept, NotificationReason::Subscribe => NotificationReason::Subscribe, NotificationReason::SubscribeAccept => NotificationReason::SubscribeAccept, NotificationReason::CollaborationInvite => { NotificationReason::CollaborationInvite } NotificationReason::CollaborationAccept => { NotificationReason::CollaborationAccept } NotificationReason::NewEntry => NotificationReason::NewEntry, NotificationReason::EntryUpdate => NotificationReason::EntryUpdate, NotificationReason::Mention => NotificationReason::Mention, NotificationReason::Tag => NotificationReason::Tag, NotificationReason::Comment => NotificationReason::Comment, NotificationReason::Other(v) => NotificationReason::Other(v.into_static()), } } } /// New content from a notebook subscription. #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct SubscriptionUpdateView<'a> { /// New entries since last check. #[serde(borrow)] pub new_entries: Vec>, #[serde(borrow)] pub notebook: crate::sh_weaver::notebook::NotebookView<'a>, pub updated_at: jacquard_common::types::string::Datetime, /// Entries that were updated. #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub updated_entries: std::option::Option< Vec>, >, } pub mod subscription_update_view_state { pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; #[allow(unused)] use ::core::marker::PhantomData; mod sealed { pub trait Sealed {} } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { type NewEntries; type Notebook; type UpdatedAt; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type NewEntries = Unset; type Notebook = Unset; type UpdatedAt = Unset; } ///State transition - sets the `new_entries` field to Set pub struct SetNewEntries(PhantomData S>); impl sealed::Sealed for SetNewEntries {} impl State for SetNewEntries { type NewEntries = Set; type Notebook = S::Notebook; type UpdatedAt = S::UpdatedAt; } ///State transition - sets the `notebook` field to Set pub struct SetNotebook(PhantomData S>); impl sealed::Sealed for SetNotebook {} impl State for SetNotebook { type NewEntries = S::NewEntries; type Notebook = Set; type UpdatedAt = S::UpdatedAt; } ///State transition - sets the `updated_at` field to Set pub struct SetUpdatedAt(PhantomData S>); impl sealed::Sealed for SetUpdatedAt {} impl State for SetUpdatedAt { type NewEntries = S::NewEntries; type Notebook = S::Notebook; type UpdatedAt = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `new_entries` field pub struct new_entries(()); ///Marker type for the `notebook` field pub struct notebook(()); ///Marker type for the `updated_at` field pub struct updated_at(()); } } /// Builder for constructing an instance of this type pub struct SubscriptionUpdateViewBuilder<'a, S: subscription_update_view_state::State> { _phantom_state: ::core::marker::PhantomData S>, __unsafe_private_named: ( ::core::option::Option>>, ::core::option::Option>, ::core::option::Option, ::core::option::Option>>, ), _phantom: ::core::marker::PhantomData<&'a ()>, } impl<'a> SubscriptionUpdateView<'a> { /// Create a new builder for this type pub fn new() -> SubscriptionUpdateViewBuilder< 'a, subscription_update_view_state::Empty, > { SubscriptionUpdateViewBuilder::new() } } impl<'a> SubscriptionUpdateViewBuilder<'a, subscription_update_view_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { SubscriptionUpdateViewBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: (None, None, None, None), _phantom: ::core::marker::PhantomData, } } } impl<'a, S> SubscriptionUpdateViewBuilder<'a, S> where S: subscription_update_view_state::State, S::NewEntries: subscription_update_view_state::IsUnset, { /// Set the `newEntries` field (required) pub fn new_entries( mut self, value: impl Into>>, ) -> SubscriptionUpdateViewBuilder< 'a, subscription_update_view_state::SetNewEntries, > { self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); SubscriptionUpdateViewBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> SubscriptionUpdateViewBuilder<'a, S> where S: subscription_update_view_state::State, S::Notebook: subscription_update_view_state::IsUnset, { /// Set the `notebook` field (required) pub fn notebook( mut self, value: impl Into>, ) -> SubscriptionUpdateViewBuilder< 'a, subscription_update_view_state::SetNotebook, > { self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); SubscriptionUpdateViewBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> SubscriptionUpdateViewBuilder<'a, S> where S: subscription_update_view_state::State, S::UpdatedAt: subscription_update_view_state::IsUnset, { /// Set the `updatedAt` field (required) pub fn updated_at( mut self, value: impl Into, ) -> SubscriptionUpdateViewBuilder< 'a, subscription_update_view_state::SetUpdatedAt, > { self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into()); SubscriptionUpdateViewBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S: subscription_update_view_state::State> SubscriptionUpdateViewBuilder<'a, S> { /// Set the `updatedEntries` field (optional) pub fn updated_entries( mut self, value: impl Into>>>, ) -> Self { self.__unsafe_private_named.3 = value.into(); self } /// Set the `updatedEntries` field to an Option value (optional) pub fn maybe_updated_entries( mut self, value: Option>>, ) -> Self { self.__unsafe_private_named.3 = value; self } } impl<'a, S> SubscriptionUpdateViewBuilder<'a, S> where S: subscription_update_view_state::State, S::NewEntries: subscription_update_view_state::IsSet, S::Notebook: subscription_update_view_state::IsSet, S::UpdatedAt: subscription_update_view_state::IsSet, { /// Build the final struct pub fn build(self) -> SubscriptionUpdateView<'a> { SubscriptionUpdateView { new_entries: self.__unsafe_private_named.0.unwrap(), notebook: self.__unsafe_private_named.1.unwrap(), updated_at: self.__unsafe_private_named.2.unwrap(), updated_entries: self.__unsafe_private_named.3, extra_data: Default::default(), } } /// Build the final struct with custom extra_data pub fn build_with_data( self, extra_data: std::collections::BTreeMap< jacquard_common::smol_str::SmolStr, jacquard_common::types::value::Data<'a>, >, ) -> SubscriptionUpdateView<'a> { SubscriptionUpdateView { new_entries: self.__unsafe_private_named.0.unwrap(), notebook: self.__unsafe_private_named.1.unwrap(), updated_at: self.__unsafe_private_named.2.unwrap(), updated_entries: self.__unsafe_private_named.3, extra_data: Some(extra_data), } } } impl<'a> ::jacquard_lexicon::schema::LexiconSchema for SubscriptionUpdateView<'a> { fn nsid() -> &'static str { "sh.weaver.notification.defs" } fn def_name() -> &'static str { "subscriptionUpdateView" } fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { lexicon_doc_sh_weaver_notification_defs() } fn validate( &self, ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { Ok(()) } }