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::CowStr;
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::string::{AtUri, Cid, Datetime};
use jacquard_common::types::value::Data;
use jacquard_derive::{IntoStatic, lexicon, open_union};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::sh_weaver::actor::ProfileViewBasic;
use crate::sh_weaver::notebook::EntryView;
use crate::sh_weaver::notebook::NotebookView;
use crate::sh_weaver::notification;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Notification<'a> {
#[serde(borrow)]
pub author: ProfileViewBasic<'a>,
#[serde(borrow)]
pub cid: Cid<'a>,
pub indexed_at: Datetime,
pub is_read: bool,
#[serde(borrow)]
pub reason: notification::NotificationReason<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub reason_subject: Option<AtUri<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub record: Option<Data<'a>>,
#[serde(borrow)]
pub uri: AtUri<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct NotificationGroup<'a> {
#[serde(borrow)]
pub actors: Vec<ProfileViewBasic<'a>>,
pub count: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub is_read: Option<bool>,
pub most_recent_at: Datetime,
#[serde(borrow)]
pub reason: notification::NotificationReason<'a>,
#[serde(borrow)]
pub subject: NotificationGroupSubject<'a>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum NotificationGroupSubject<'a> {
#[serde(rename = "sh.weaver.notebook.defs#notebookView")]
NotebookView(Box<NotebookView<'a>>),
#[serde(rename = "sh.weaver.notebook.defs#entryView")]
EntryView(Box<EntryView<'a>>),
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum NotificationReason<'a> {
Like,
Bookmark,
Follow,
FollowAccept,
Subscribe,
SubscribeAccept,
CollaborationInvite,
CollaborationAccept,
NewEntry,
EntryUpdate,
Mention,
Tag,
Comment,
Other(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(CowStr::from(s)),
}
}
}
impl<'a> From<String> 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(CowStr::from(s)),
}
}
}
impl<'a> AsRef<str> 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<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, 'a> serde::Deserialize<'de> for NotificationReason<'a>
where
'de: 'a,
{
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
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()),
}
}
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct SubscriptionUpdateView<'a> {
#[serde(borrow)]
pub new_entries: Vec<EntryView<'a>>,
#[serde(borrow)]
pub notebook: NotebookView<'a>,
pub updated_at: Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub updated_entries: Option<Vec<EntryView<'a>>>,
}
impl<'a> LexiconSchema for Notification<'a> {
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<'a> LexiconSchema for NotificationGroup<'a> {
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<'a> LexiconSchema for SubscriptionUpdateView<'a> {
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::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Cid;
type Uri;
type Author;
type Reason;
type IndexedAt;
type IsRead;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Cid = Unset;
type Uri = Unset;
type Author = Unset;
type Reason = Unset;
type IndexedAt = Unset;
type IsRead = Unset;
}
pub struct SetCid<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetCid<S> {}
impl<S: State> State for SetCid<S> {
type Cid = Set<members::cid>;
type Uri = S::Uri;
type Author = S::Author;
type Reason = S::Reason;
type IndexedAt = S::IndexedAt;
type IsRead = S::IsRead;
}
pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetUri<S> {}
impl<S: State> State for SetUri<S> {
type Cid = S::Cid;
type Uri = Set<members::uri>;
type Author = S::Author;
type Reason = S::Reason;
type IndexedAt = S::IndexedAt;
type IsRead = S::IsRead;
}
pub struct SetAuthor<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetAuthor<S> {}
impl<S: State> State for SetAuthor<S> {
type Cid = S::Cid;
type Uri = S::Uri;
type Author = Set<members::author>;
type Reason = S::Reason;
type IndexedAt = S::IndexedAt;
type IsRead = S::IsRead;
}
pub struct SetReason<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetReason<S> {}
impl<S: State> State for SetReason<S> {
type Cid = S::Cid;
type Uri = S::Uri;
type Author = S::Author;
type Reason = Set<members::reason>;
type IndexedAt = S::IndexedAt;
type IsRead = S::IsRead;
}
pub struct SetIndexedAt<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetIndexedAt<S> {}
impl<S: State> State for SetIndexedAt<S> {
type Cid = S::Cid;
type Uri = S::Uri;
type Author = S::Author;
type Reason = S::Reason;
type IndexedAt = Set<members::indexed_at>;
type IsRead = S::IsRead;
}
pub struct SetIsRead<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetIsRead<S> {}
impl<S: State> State for SetIsRead<S> {
type Cid = S::Cid;
type Uri = S::Uri;
type Author = S::Author;
type Reason = S::Reason;
type IndexedAt = S::IndexedAt;
type IsRead = Set<members::is_read>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct cid(());
pub struct uri(());
pub struct author(());
pub struct reason(());
pub struct indexed_at(());
pub struct is_read(());
}
}
pub struct NotificationBuilder<'a, S: notification_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<ProfileViewBasic<'a>>,
Option<Cid<'a>>,
Option<Datetime>,
Option<bool>,
Option<notification::NotificationReason<'a>>,
Option<AtUri<'a>>,
Option<Data<'a>>,
Option<AtUri<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Notification<'a> {
pub fn new() -> NotificationBuilder<'a, notification_state::Empty> {
NotificationBuilder::new()
}
}
impl<'a> NotificationBuilder<'a, notification_state::Empty> {
pub fn new() -> Self {
NotificationBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> NotificationBuilder<'a, S>
where
S: notification_state::State,
S::Author: notification_state::IsUnset,
{
pub fn author(
mut self,
value: impl Into<ProfileViewBasic<'a>>,
) -> NotificationBuilder<'a, notification_state::SetAuthor<S>> {
self._fields.0 = Option::Some(value.into());
NotificationBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> NotificationBuilder<'a, S>
where
S: notification_state::State,
S::Cid: notification_state::IsUnset,
{
pub fn cid(
mut self,
value: impl Into<Cid<'a>>,
) -> NotificationBuilder<'a, notification_state::SetCid<S>> {
self._fields.1 = Option::Some(value.into());
NotificationBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> NotificationBuilder<'a, S>
where
S: notification_state::State,
S::IndexedAt: notification_state::IsUnset,
{
pub fn indexed_at(
mut self,
value: impl Into<Datetime>,
) -> NotificationBuilder<'a, notification_state::SetIndexedAt<S>> {
self._fields.2 = Option::Some(value.into());
NotificationBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> NotificationBuilder<'a, S>
where
S: notification_state::State,
S::IsRead: notification_state::IsUnset,
{
pub fn is_read(
mut self,
value: impl Into<bool>,
) -> NotificationBuilder<'a, notification_state::SetIsRead<S>> {
self._fields.3 = Option::Some(value.into());
NotificationBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> NotificationBuilder<'a, S>
where
S: notification_state::State,
S::Reason: notification_state::IsUnset,
{
pub fn reason(
mut self,
value: impl Into<notification::NotificationReason<'a>>,
) -> NotificationBuilder<'a, notification_state::SetReason<S>> {
self._fields.4 = Option::Some(value.into());
NotificationBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: notification_state::State> NotificationBuilder<'a, S> {
pub fn reason_subject(mut self, value: impl Into<Option<AtUri<'a>>>) -> Self {
self._fields.5 = value.into();
self
}
pub fn maybe_reason_subject(mut self, value: Option<AtUri<'a>>) -> Self {
self._fields.5 = value;
self
}
}
impl<'a, S: notification_state::State> NotificationBuilder<'a, S> {
pub fn record(mut self, value: impl Into<Option<Data<'a>>>) -> Self {
self._fields.6 = value.into();
self
}
pub fn maybe_record(mut self, value: Option<Data<'a>>) -> Self {
self._fields.6 = value;
self
}
}
impl<'a, S> NotificationBuilder<'a, S>
where
S: notification_state::State,
S::Uri: notification_state::IsUnset,
{
pub fn uri(
mut self,
value: impl Into<AtUri<'a>>,
) -> NotificationBuilder<'a, notification_state::SetUri<S>> {
self._fields.7 = Option::Some(value.into());
NotificationBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> NotificationBuilder<'a, S>
where
S: notification_state::State,
S::Cid: notification_state::IsSet,
S::Uri: notification_state::IsSet,
S::Author: notification_state::IsSet,
S::Reason: notification_state::IsSet,
S::IndexedAt: notification_state::IsSet,
S::IsRead: notification_state::IsSet,
{
pub fn build(self) -> Notification<'a> {
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<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
) -> Notification<'a> {
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> {
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
use alloc::collections::BTreeMap;
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::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Reason;
type MostRecentAt;
type Count;
type Subject;
type Actors;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Reason = Unset;
type MostRecentAt = Unset;
type Count = Unset;
type Subject = Unset;
type Actors = Unset;
}
pub struct SetReason<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetReason<S> {}
impl<S: State> State for SetReason<S> {
type Reason = Set<members::reason>;
type MostRecentAt = S::MostRecentAt;
type Count = S::Count;
type Subject = S::Subject;
type Actors = S::Actors;
}
pub struct SetMostRecentAt<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetMostRecentAt<S> {}
impl<S: State> State for SetMostRecentAt<S> {
type Reason = S::Reason;
type MostRecentAt = Set<members::most_recent_at>;
type Count = S::Count;
type Subject = S::Subject;
type Actors = S::Actors;
}
pub struct SetCount<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetCount<S> {}
impl<S: State> State for SetCount<S> {
type Reason = S::Reason;
type MostRecentAt = S::MostRecentAt;
type Count = Set<members::count>;
type Subject = S::Subject;
type Actors = S::Actors;
}
pub struct SetSubject<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetSubject<S> {}
impl<S: State> State for SetSubject<S> {
type Reason = S::Reason;
type MostRecentAt = S::MostRecentAt;
type Count = S::Count;
type Subject = Set<members::subject>;
type Actors = S::Actors;
}
pub struct SetActors<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetActors<S> {}
impl<S: State> State for SetActors<S> {
type Reason = S::Reason;
type MostRecentAt = S::MostRecentAt;
type Count = S::Count;
type Subject = S::Subject;
type Actors = Set<members::actors>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct reason(());
pub struct most_recent_at(());
pub struct count(());
pub struct subject(());
pub struct actors(());
}
}
pub struct NotificationGroupBuilder<'a, S: notification_group_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<Vec<ProfileViewBasic<'a>>>,
Option<i64>,
Option<bool>,
Option<Datetime>,
Option<notification::NotificationReason<'a>>,
Option<NotificationGroupSubject<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> NotificationGroup<'a> {
pub fn new() -> NotificationGroupBuilder<'a, notification_group_state::Empty> {
NotificationGroupBuilder::new()
}
}
impl<'a> NotificationGroupBuilder<'a, notification_group_state::Empty> {
pub fn new() -> Self {
NotificationGroupBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> NotificationGroupBuilder<'a, S>
where
S: notification_group_state::State,
S::Actors: notification_group_state::IsUnset,
{
pub fn actors(
mut self,
value: impl Into<Vec<ProfileViewBasic<'a>>>,
) -> NotificationGroupBuilder<'a, notification_group_state::SetActors<S>> {
self._fields.0 = Option::Some(value.into());
NotificationGroupBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> NotificationGroupBuilder<'a, S>
where
S: notification_group_state::State,
S::Count: notification_group_state::IsUnset,
{
pub fn count(
mut self,
value: impl Into<i64>,
) -> NotificationGroupBuilder<'a, notification_group_state::SetCount<S>> {
self._fields.1 = Option::Some(value.into());
NotificationGroupBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: notification_group_state::State> NotificationGroupBuilder<'a, S> {
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<'a, S> NotificationGroupBuilder<'a, S>
where
S: notification_group_state::State,
S::MostRecentAt: notification_group_state::IsUnset,
{
pub fn most_recent_at(
mut self,
value: impl Into<Datetime>,
) -> NotificationGroupBuilder<'a, notification_group_state::SetMostRecentAt<S>> {
self._fields.3 = Option::Some(value.into());
NotificationGroupBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> NotificationGroupBuilder<'a, S>
where
S: notification_group_state::State,
S::Reason: notification_group_state::IsUnset,
{
pub fn reason(
mut self,
value: impl Into<notification::NotificationReason<'a>>,
) -> NotificationGroupBuilder<'a, notification_group_state::SetReason<S>> {
self._fields.4 = Option::Some(value.into());
NotificationGroupBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> NotificationGroupBuilder<'a, S>
where
S: notification_group_state::State,
S::Subject: notification_group_state::IsUnset,
{
pub fn subject(
mut self,
value: impl Into<NotificationGroupSubject<'a>>,
) -> NotificationGroupBuilder<'a, notification_group_state::SetSubject<S>> {
self._fields.5 = Option::Some(value.into());
NotificationGroupBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> NotificationGroupBuilder<'a, S>
where
S: notification_group_state::State,
S::Reason: notification_group_state::IsSet,
S::MostRecentAt: notification_group_state::IsSet,
S::Count: notification_group_state::IsSet,
S::Subject: notification_group_state::IsSet,
S::Actors: notification_group_state::IsSet,
{
pub fn build(self) -> NotificationGroup<'a> {
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<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
) -> NotificationGroup<'a> {
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::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type NewEntries;
type UpdatedAt;
type Notebook;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type NewEntries = Unset;
type UpdatedAt = Unset;
type Notebook = Unset;
}
pub struct SetNewEntries<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetNewEntries<S> {}
impl<S: State> State for SetNewEntries<S> {
type NewEntries = Set<members::new_entries>;
type UpdatedAt = S::UpdatedAt;
type Notebook = S::Notebook;
}
pub struct SetUpdatedAt<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetUpdatedAt<S> {}
impl<S: State> State for SetUpdatedAt<S> {
type NewEntries = S::NewEntries;
type UpdatedAt = Set<members::updated_at>;
type Notebook = S::Notebook;
}
pub struct SetNotebook<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetNotebook<S> {}
impl<S: State> State for SetNotebook<S> {
type NewEntries = S::NewEntries;
type UpdatedAt = S::UpdatedAt;
type Notebook = Set<members::notebook>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct new_entries(());
pub struct updated_at(());
pub struct notebook(());
}
}
pub struct SubscriptionUpdateViewBuilder<'a, S: subscription_update_view_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<Vec<EntryView<'a>>>,
Option<NotebookView<'a>>,
Option<Datetime>,
Option<Vec<EntryView<'a>>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> SubscriptionUpdateView<'a> {
pub fn new() -> SubscriptionUpdateViewBuilder<
'a,
subscription_update_view_state::Empty,
> {
SubscriptionUpdateViewBuilder::new()
}
}
impl<'a> SubscriptionUpdateViewBuilder<'a, subscription_update_view_state::Empty> {
pub fn new() -> Self {
SubscriptionUpdateViewBuilder {
_state: PhantomData,
_fields: (None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> SubscriptionUpdateViewBuilder<'a, S>
where
S: subscription_update_view_state::State,
S::NewEntries: subscription_update_view_state::IsUnset,
{
pub fn new_entries(
mut self,
value: impl Into<Vec<EntryView<'a>>>,
) -> SubscriptionUpdateViewBuilder<
'a,
subscription_update_view_state::SetNewEntries<S>,
> {
self._fields.0 = Option::Some(value.into());
SubscriptionUpdateViewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> SubscriptionUpdateViewBuilder<'a, S>
where
S: subscription_update_view_state::State,
S::Notebook: subscription_update_view_state::IsUnset,
{
pub fn notebook(
mut self,
value: impl Into<NotebookView<'a>>,
) -> SubscriptionUpdateViewBuilder<
'a,
subscription_update_view_state::SetNotebook<S>,
> {
self._fields.1 = Option::Some(value.into());
SubscriptionUpdateViewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> SubscriptionUpdateViewBuilder<'a, S>
where
S: subscription_update_view_state::State,
S::UpdatedAt: subscription_update_view_state::IsUnset,
{
pub fn updated_at(
mut self,
value: impl Into<Datetime>,
) -> SubscriptionUpdateViewBuilder<
'a,
subscription_update_view_state::SetUpdatedAt<S>,
> {
self._fields.2 = Option::Some(value.into());
SubscriptionUpdateViewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: subscription_update_view_state::State> SubscriptionUpdateViewBuilder<'a, S> {
pub fn updated_entries(
mut self,
value: impl Into<Option<Vec<EntryView<'a>>>>,
) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_updated_entries(mut self, value: Option<Vec<EntryView<'a>>>) -> Self {
self._fields.3 = value;
self
}
}
impl<'a, S> SubscriptionUpdateViewBuilder<'a, S>
where
S: subscription_update_view_state::State,
S::NewEntries: subscription_update_view_state::IsSet,
S::UpdatedAt: subscription_update_view_state::IsSet,
S::Notebook: subscription_update_view_state::IsSet,
{
pub fn build(self) -> SubscriptionUpdateView<'a> {
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<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
) -> SubscriptionUpdateView<'a> {
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),
}
}
}