pub mod get_subscription_updates;
pub mod get_unread_count;
pub mod list_notifications;
pub mod update_seen;
#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{BosStr, CowStr, DefaultStr, FromStaticStr};
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::{AtUri, Cid, Datetime};
use jacquard_common::types::value::Data;
use jacquard_derive::{IntoStatic, open_union};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
use crate::sh_weaver::actor::ProfileViewBasic;
use crate::sh_weaver::notebook::EntryView;
use crate::sh_weaver::notebook::NotebookView;
use crate::sh_weaver::notification;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Notification<S: BosStr = DefaultStr> {
pub author: ProfileViewBasic<S>,
pub cid: Cid<S>,
pub indexed_at: Datetime,
pub is_read: bool,
pub reason: notification::NotificationReason<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub reason_subject: Option<AtUri<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub record: Option<Data<S>>,
pub uri: AtUri<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct NotificationGroup<S: BosStr = DefaultStr> {
pub actors: Vec<ProfileViewBasic<S>>,
pub count: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub is_read: Option<bool>,
pub most_recent_at: Datetime,
pub reason: notification::NotificationReason<S>,
pub subject: NotificationGroupSubject<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum NotificationGroupSubject<S: BosStr = DefaultStr> {
#[serde(rename = "sh.weaver.notebook.defs#notebookView")]
NotebookView(Box<NotebookView<S>>),
#[serde(rename = "sh.weaver.notebook.defs#entryView")]
EntryView(Box<EntryView<S>>),
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum NotificationReason<S: BosStr = DefaultStr> {
Like,
Bookmark,
Follow,
FollowAccept,
Subscribe,
SubscribeAccept,
CollaborationInvite,
CollaborationAccept,
NewEntry,
EntryUpdate,
Mention,
Tag,
Comment,
Other(S),
}
impl<S: BosStr> NotificationReason<S> {
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(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"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(s),
}
}
}
impl<S: BosStr> AsRef<str> for NotificationReason<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> core::fmt::Display for NotificationReason<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> Serialize for NotificationReason<S> {
fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
where
Ser: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for NotificationReason<S> {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = S::deserialize(deserializer)?;
Ok(Self::from_value(s))
}
}
impl<S: BosStr> jacquard_common::IntoStatic for NotificationReason<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = NotificationReason<S::Output>;
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()),
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct SubscriptionUpdateView<S: BosStr = DefaultStr> {
pub new_entries: Vec<EntryView<S>>,
pub notebook: NotebookView<S>,
pub updated_at: Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
pub updated_entries: Option<Vec<EntryView<S>>>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
impl<S: BosStr> LexiconSchema for Notification<S> {
fn nsid() -> &'static str {
"sh.weaver.notification.defs"
}
fn def_name() -> &'static str {
"notification"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_weaver_notification_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for NotificationGroup<S> {
fn nsid() -> &'static str {
"sh.weaver.notification.defs"
}
fn def_name() -> &'static str {
"notificationGroup"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_weaver_notification_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.actors;
#[allow(unused_comparisons)]
if value.len() > 5usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("actors"),
max: 5usize,
actual: value.len(),
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for SubscriptionUpdateView<S> {
fn nsid() -> &'static str {
"sh.weaver.notification.defs"
}
fn def_name() -> &'static str {
"subscriptionUpdateView"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_weaver_notification_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod notification_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Cid;
type Uri;
type Reason;
type IsRead;
type IndexedAt;
type Author;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Cid = Unset;
type Uri = Unset;
type Reason = Unset;
type IsRead = Unset;
type IndexedAt = Unset;
type Author = Unset;
}
pub struct SetCid<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCid<St> {}
impl<St: State> State for SetCid<St> {
type Cid = Set<members::cid>;
type Uri = St::Uri;
type Reason = St::Reason;
type IsRead = St::IsRead;
type IndexedAt = St::IndexedAt;
type Author = St::Author;
}
pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetUri<St> {}
impl<St: State> State for SetUri<St> {
type Cid = St::Cid;
type Uri = Set<members::uri>;
type Reason = St::Reason;
type IsRead = St::IsRead;
type IndexedAt = St::IndexedAt;
type Author = St::Author;
}
pub struct SetReason<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetReason<St> {}
impl<St: State> State for SetReason<St> {
type Cid = St::Cid;
type Uri = St::Uri;
type Reason = Set<members::reason>;
type IsRead = St::IsRead;
type IndexedAt = St::IndexedAt;
type Author = St::Author;
}
pub struct SetIsRead<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetIsRead<St> {}
impl<St: State> State for SetIsRead<St> {
type Cid = St::Cid;
type Uri = St::Uri;
type Reason = St::Reason;
type IsRead = Set<members::is_read>;
type IndexedAt = St::IndexedAt;
type Author = St::Author;
}
pub struct SetIndexedAt<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetIndexedAt<St> {}
impl<St: State> State for SetIndexedAt<St> {
type Cid = St::Cid;
type Uri = St::Uri;
type Reason = St::Reason;
type IsRead = St::IsRead;
type IndexedAt = Set<members::indexed_at>;
type Author = St::Author;
}
pub struct SetAuthor<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetAuthor<St> {}
impl<St: State> State for SetAuthor<St> {
type Cid = St::Cid;
type Uri = St::Uri;
type Reason = St::Reason;
type IsRead = St::IsRead;
type IndexedAt = St::IndexedAt;
type Author = Set<members::author>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct cid(());
pub struct uri(());
pub struct reason(());
pub struct is_read(());
pub struct indexed_at(());
pub struct author(());
}
}
pub struct NotificationBuilder<S: BosStr, St: notification_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<ProfileViewBasic<S>>,
Option<Cid<S>>,
Option<Datetime>,
Option<bool>,
Option<notification::NotificationReason<S>>,
Option<AtUri<S>>,
Option<Data<S>>,
Option<AtUri<S>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Notification<S> {
pub fn new() -> NotificationBuilder<S, notification_state::Empty> {
NotificationBuilder::new()
}
}
impl<S: BosStr> NotificationBuilder<S, notification_state::Empty> {
pub fn new() -> Self {
NotificationBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> NotificationBuilder<S, St>
where
St: notification_state::State,
St::Author: notification_state::IsUnset,
{
pub fn author(
mut self,
value: impl Into<ProfileViewBasic<S>>,
) -> NotificationBuilder<S, notification_state::SetAuthor<St>> {
self._fields.0 = Option::Some(value.into());
NotificationBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> NotificationBuilder<S, St>
where
St: notification_state::State,
St::Cid: notification_state::IsUnset,
{
pub fn cid(
mut self,
value: impl Into<Cid<S>>,
) -> NotificationBuilder<S, notification_state::SetCid<St>> {
self._fields.1 = Option::Some(value.into());
NotificationBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> NotificationBuilder<S, St>
where
St: notification_state::State,
St::IndexedAt: notification_state::IsUnset,
{
pub fn indexed_at(
mut self,
value: impl Into<Datetime>,
) -> NotificationBuilder<S, notification_state::SetIndexedAt<St>> {
self._fields.2 = Option::Some(value.into());
NotificationBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> NotificationBuilder<S, St>
where
St: notification_state::State,
St::IsRead: notification_state::IsUnset,
{
pub fn is_read(
mut self,
value: impl Into<bool>,
) -> NotificationBuilder<S, notification_state::SetIsRead<St>> {
self._fields.3 = Option::Some(value.into());
NotificationBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> NotificationBuilder<S, St>
where
St: notification_state::State,
St::Reason: notification_state::IsUnset,
{
pub fn reason(
mut self,
value: impl Into<notification::NotificationReason<S>>,
) -> NotificationBuilder<S, notification_state::SetReason<St>> {
self._fields.4 = Option::Some(value.into());
NotificationBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: notification_state::State> NotificationBuilder<S, St> {
pub fn reason_subject(mut self, value: impl Into<Option<AtUri<S>>>) -> Self {
self._fields.5 = value.into();
self
}
pub fn maybe_reason_subject(mut self, value: Option<AtUri<S>>) -> Self {
self._fields.5 = value;
self
}
}
impl<S: BosStr, St: notification_state::State> NotificationBuilder<S, St> {
pub fn record(mut self, value: impl Into<Option<Data<S>>>) -> Self {
self._fields.6 = value.into();
self
}
pub fn maybe_record(mut self, value: Option<Data<S>>) -> Self {
self._fields.6 = value;
self
}
}
impl<S: BosStr, St> NotificationBuilder<S, St>
where
St: notification_state::State,
St::Uri: notification_state::IsUnset,
{
pub fn uri(
mut self,
value: impl Into<AtUri<S>>,
) -> NotificationBuilder<S, notification_state::SetUri<St>> {
self._fields.7 = Option::Some(value.into());
NotificationBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> NotificationBuilder<S, St>
where
St: notification_state::State,
St::Cid: notification_state::IsSet,
St::Uri: notification_state::IsSet,
St::Reason: notification_state::IsSet,
St::IsRead: notification_state::IsSet,
St::IndexedAt: notification_state::IsSet,
St::Author: notification_state::IsSet,
{
pub fn build(self) -> Notification<S> {
Notification {
author: self._fields.0.unwrap(),
cid: self._fields.1.unwrap(),
indexed_at: self._fields.2.unwrap(),
is_read: self._fields.3.unwrap(),
reason: self._fields.4.unwrap(),
reason_subject: self._fields.5,
record: self._fields.6,
uri: self._fields.7.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Notification<S> {
Notification {
author: self._fields.0.unwrap(),
cid: self._fields.1.unwrap(),
indexed_at: self._fields.2.unwrap(),
is_read: self._fields.3.unwrap(),
reason: self._fields.4.unwrap(),
reason_subject: self._fields.5,
record: self._fields.6,
uri: self._fields.7.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_sh_weaver_notification_defs() -> LexiconDoc<'static> {
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
LexiconDoc {
lexicon: Lexicon::Lexicon1,
id: CowStr::new_static("sh.weaver.notification.defs"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("notification"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static("A notification for a user.")),
required: Some(vec![
SmolStr::new_static("uri"),
SmolStr::new_static("cid"),
SmolStr::new_static("author"),
SmolStr::new_static("reason"),
SmolStr::new_static("isRead"),
SmolStr::new_static("indexedAt"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("author"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("sh.weaver.actor.defs#profileViewBasic"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("cid"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Cid),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("indexedAt"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("isRead"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("reason"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#notificationReason"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("reasonSubject"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"The subject of the notification (entry, notebook, etc).",
)),
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("record"),
LexObjectProperty::Unknown(LexUnknown {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("uri"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("notificationGroup"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static(
"Grouped notifications (e.g., '5 people liked your entry').",
)),
required: Some(vec![
SmolStr::new_static("reason"),
SmolStr::new_static("subject"),
SmolStr::new_static("count"),
SmolStr::new_static("actors"),
SmolStr::new_static("mostRecentAt"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("actors"),
LexObjectProperty::Array(LexArray {
description: Some(CowStr::new_static(
"Most recent actors (up to 5).",
)),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static(
"sh.weaver.actor.defs#profileViewBasic",
),
..Default::default()
}),
max_length: Some(5usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("count"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("isRead"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("mostRecentAt"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("reason"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#notificationReason"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("subject"),
LexObjectProperty::Union(LexRefUnion {
refs: vec![
CowStr::new_static("sh.weaver.notebook.defs#notebookView"),
CowStr::new_static("sh.weaver.notebook.defs#entryView"),
],
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("notificationReason"),
LexUserType::String(LexString {
description: Some(CowStr::new_static("Why this notification was generated.")),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("subscriptionUpdateView"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static(
"New content from a notebook subscription.",
)),
required: Some(vec![
SmolStr::new_static("notebook"),
SmolStr::new_static("newEntries"),
SmolStr::new_static("updatedAt"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("newEntries"),
LexObjectProperty::Array(LexArray {
description: Some(CowStr::new_static(
"New entries since last check.",
)),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("sh.weaver.notebook.defs#entryView"),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("notebook"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("sh.weaver.notebook.defs#notebookView"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("updatedAt"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("updatedEntries"),
LexObjectProperty::Array(LexArray {
description: Some(CowStr::new_static("Entries that were updated.")),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("sh.weaver.notebook.defs#entryView"),
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod notification_group_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Reason;
type Actors;
type Count;
type MostRecentAt;
type Subject;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Reason = Unset;
type Actors = Unset;
type Count = Unset;
type MostRecentAt = Unset;
type Subject = Unset;
}
pub struct SetReason<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetReason<St> {}
impl<St: State> State for SetReason<St> {
type Reason = Set<members::reason>;
type Actors = St::Actors;
type Count = St::Count;
type MostRecentAt = St::MostRecentAt;
type Subject = St::Subject;
}
pub struct SetActors<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetActors<St> {}
impl<St: State> State for SetActors<St> {
type Reason = St::Reason;
type Actors = Set<members::actors>;
type Count = St::Count;
type MostRecentAt = St::MostRecentAt;
type Subject = St::Subject;
}
pub struct SetCount<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCount<St> {}
impl<St: State> State for SetCount<St> {
type Reason = St::Reason;
type Actors = St::Actors;
type Count = Set<members::count>;
type MostRecentAt = St::MostRecentAt;
type Subject = St::Subject;
}
pub struct SetMostRecentAt<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetMostRecentAt<St> {}
impl<St: State> State for SetMostRecentAt<St> {
type Reason = St::Reason;
type Actors = St::Actors;
type Count = St::Count;
type MostRecentAt = Set<members::most_recent_at>;
type Subject = St::Subject;
}
pub struct SetSubject<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSubject<St> {}
impl<St: State> State for SetSubject<St> {
type Reason = St::Reason;
type Actors = St::Actors;
type Count = St::Count;
type MostRecentAt = St::MostRecentAt;
type Subject = Set<members::subject>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct reason(());
pub struct actors(());
pub struct count(());
pub struct most_recent_at(());
pub struct subject(());
}
}
pub struct NotificationGroupBuilder<S: BosStr, St: notification_group_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<Vec<ProfileViewBasic<S>>>,
Option<i64>,
Option<bool>,
Option<Datetime>,
Option<notification::NotificationReason<S>>,
Option<NotificationGroupSubject<S>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> NotificationGroup<S> {
pub fn new() -> NotificationGroupBuilder<S, notification_group_state::Empty> {
NotificationGroupBuilder::new()
}
}
impl<S: BosStr> NotificationGroupBuilder<S, notification_group_state::Empty> {
pub fn new() -> Self {
NotificationGroupBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> NotificationGroupBuilder<S, St>
where
St: notification_group_state::State,
St::Actors: notification_group_state::IsUnset,
{
pub fn actors(
mut self,
value: impl Into<Vec<ProfileViewBasic<S>>>,
) -> NotificationGroupBuilder<S, notification_group_state::SetActors<St>> {
self._fields.0 = Option::Some(value.into());
NotificationGroupBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> NotificationGroupBuilder<S, St>
where
St: notification_group_state::State,
St::Count: notification_group_state::IsUnset,
{
pub fn count(
mut self,
value: impl Into<i64>,
) -> NotificationGroupBuilder<S, notification_group_state::SetCount<St>> {
self._fields.1 = Option::Some(value.into());
NotificationGroupBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: notification_group_state::State> NotificationGroupBuilder<S, St> {
pub fn is_read(mut self, value: impl Into<Option<bool>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_is_read(mut self, value: Option<bool>) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St> NotificationGroupBuilder<S, St>
where
St: notification_group_state::State,
St::MostRecentAt: notification_group_state::IsUnset,
{
pub fn most_recent_at(
mut self,
value: impl Into<Datetime>,
) -> NotificationGroupBuilder<S, notification_group_state::SetMostRecentAt<St>> {
self._fields.3 = Option::Some(value.into());
NotificationGroupBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> NotificationGroupBuilder<S, St>
where
St: notification_group_state::State,
St::Reason: notification_group_state::IsUnset,
{
pub fn reason(
mut self,
value: impl Into<notification::NotificationReason<S>>,
) -> NotificationGroupBuilder<S, notification_group_state::SetReason<St>> {
self._fields.4 = Option::Some(value.into());
NotificationGroupBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> NotificationGroupBuilder<S, St>
where
St: notification_group_state::State,
St::Subject: notification_group_state::IsUnset,
{
pub fn subject(
mut self,
value: impl Into<NotificationGroupSubject<S>>,
) -> NotificationGroupBuilder<S, notification_group_state::SetSubject<St>> {
self._fields.5 = Option::Some(value.into());
NotificationGroupBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> NotificationGroupBuilder<S, St>
where
St: notification_group_state::State,
St::Reason: notification_group_state::IsSet,
St::Actors: notification_group_state::IsSet,
St::Count: notification_group_state::IsSet,
St::MostRecentAt: notification_group_state::IsSet,
St::Subject: notification_group_state::IsSet,
{
pub fn build(self) -> NotificationGroup<S> {
NotificationGroup {
actors: self._fields.0.unwrap(),
count: self._fields.1.unwrap(),
is_read: self._fields.2,
most_recent_at: self._fields.3.unwrap(),
reason: self._fields.4.unwrap(),
subject: self._fields.5.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> NotificationGroup<S> {
NotificationGroup {
actors: self._fields.0.unwrap(),
count: self._fields.1.unwrap(),
is_read: self._fields.2,
most_recent_at: self._fields.3.unwrap(),
reason: self._fields.4.unwrap(),
subject: self._fields.5.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod subscription_update_view_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type UpdatedAt;
type Notebook;
type NewEntries;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type UpdatedAt = Unset;
type Notebook = Unset;
type NewEntries = Unset;
}
pub struct SetUpdatedAt<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetUpdatedAt<St> {}
impl<St: State> State for SetUpdatedAt<St> {
type UpdatedAt = Set<members::updated_at>;
type Notebook = St::Notebook;
type NewEntries = St::NewEntries;
}
pub struct SetNotebook<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetNotebook<St> {}
impl<St: State> State for SetNotebook<St> {
type UpdatedAt = St::UpdatedAt;
type Notebook = Set<members::notebook>;
type NewEntries = St::NewEntries;
}
pub struct SetNewEntries<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetNewEntries<St> {}
impl<St: State> State for SetNewEntries<St> {
type UpdatedAt = St::UpdatedAt;
type Notebook = St::Notebook;
type NewEntries = Set<members::new_entries>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct updated_at(());
pub struct notebook(());
pub struct new_entries(());
}
}
pub struct SubscriptionUpdateViewBuilder<S: BosStr, St: subscription_update_view_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<Vec<EntryView<S>>>,
Option<NotebookView<S>>,
Option<Datetime>,
Option<Vec<EntryView<S>>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> SubscriptionUpdateView<S> {
pub fn new() -> SubscriptionUpdateViewBuilder<S, subscription_update_view_state::Empty> {
SubscriptionUpdateViewBuilder::new()
}
}
impl<S: BosStr> SubscriptionUpdateViewBuilder<S, subscription_update_view_state::Empty> {
pub fn new() -> Self {
SubscriptionUpdateViewBuilder {
_state: PhantomData,
_fields: (None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SubscriptionUpdateViewBuilder<S, St>
where
St: subscription_update_view_state::State,
St::NewEntries: subscription_update_view_state::IsUnset,
{
pub fn new_entries(
mut self,
value: impl Into<Vec<EntryView<S>>>,
) -> SubscriptionUpdateViewBuilder<S, subscription_update_view_state::SetNewEntries<St>> {
self._fields.0 = Option::Some(value.into());
SubscriptionUpdateViewBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SubscriptionUpdateViewBuilder<S, St>
where
St: subscription_update_view_state::State,
St::Notebook: subscription_update_view_state::IsUnset,
{
pub fn notebook(
mut self,
value: impl Into<NotebookView<S>>,
) -> SubscriptionUpdateViewBuilder<S, subscription_update_view_state::SetNotebook<St>> {
self._fields.1 = Option::Some(value.into());
SubscriptionUpdateViewBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SubscriptionUpdateViewBuilder<S, St>
where
St: subscription_update_view_state::State,
St::UpdatedAt: subscription_update_view_state::IsUnset,
{
pub fn updated_at(
mut self,
value: impl Into<Datetime>,
) -> SubscriptionUpdateViewBuilder<S, subscription_update_view_state::SetUpdatedAt<St>> {
self._fields.2 = Option::Some(value.into());
SubscriptionUpdateViewBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: subscription_update_view_state::State> SubscriptionUpdateViewBuilder<S, St> {
pub fn updated_entries(mut self, value: impl Into<Option<Vec<EntryView<S>>>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_updated_entries(mut self, value: Option<Vec<EntryView<S>>>) -> Self {
self._fields.3 = value;
self
}
}
impl<S: BosStr, St> SubscriptionUpdateViewBuilder<S, St>
where
St: subscription_update_view_state::State,
St::UpdatedAt: subscription_update_view_state::IsSet,
St::Notebook: subscription_update_view_state::IsSet,
St::NewEntries: subscription_update_view_state::IsSet,
{
pub fn build(self) -> SubscriptionUpdateView<S> {
SubscriptionUpdateView {
new_entries: self._fields.0.unwrap(),
notebook: self._fields.1.unwrap(),
updated_at: self._fields.2.unwrap(),
updated_entries: self._fields.3,
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<SmolStr, Data<S>>,
) -> SubscriptionUpdateView<S> {
SubscriptionUpdateView {
new_entries: self._fields.0.unwrap(),
notebook: self._fields.1.unwrap(),
updated_at: self._fields.2.unwrap(),
updated_entries: self._fields.3,
extra_data: Some(extra_data),
}
}
}