rust_anilist/models/
notification.rs

1// SPDX-License-Identifier: MIT
2// Copyright (c) 2022-2025 Andriel Ferreira <https://github.com/AndrielFR>
3
4//! This module contains the `Notification` struct and its related types.
5
6use serde::{Deserialize, Serialize};
7
8/// Represents a notification.
9#[derive(Debug, Default, Clone, PartialEq, Deserialize, Serialize)]
10pub struct Notification {}
11
12/// Represents the options for a notification.
13#[derive(Debug, Default, Clone, PartialEq, Deserialize, Serialize)]
14#[serde(rename_all(deserialize = "camelCase"))]
15pub struct NotificationOption {
16    /// The type of the notification.
17    notification_type: NotificationType,
18    /// Whether the notification is enabled.
19    enabled: bool,
20}
21
22/// Represents the type of a notification.
23#[derive(Debug, Default, Clone, Eq, Hash, PartialEq, Deserialize, Serialize)]
24#[serde(rename_all(deserialize = "SCREAMING_SNAKE_CASE"))]
25pub enum NotificationType {
26    /// Notification for an activity message.
27    #[default]
28    ActivityMessage,
29    /// Notification for an activity reply.
30    ActivityReply,
31    /// Notification for a new follower.
32    Following,
33    /// Notification for an activity mention.
34    ActivityMention,
35    /// Notification for a thread comment mention.
36    ThreadCommentMention,
37    /// Notification for an airing.
38    Airing,
39    /// Notification for an activity like.
40    ActivityLike,
41    /// Notification for an activity reply like.
42    ActivityReplyLike,
43    /// Notification for a thread like.
44    ThreadLike,
45    /// Notification for being subscribed to an activity reply.
46    ActivityReplySubscribed,
47    /// Notification for a related media addition.
48    RelatedMediaAddition,
49    /// Notification for a media data change.
50    MediaDataChange,
51    /// Notification for a media merge.
52    MediaMerge,
53    /// Notification for a media deletion.
54    MediaDeletion,
55}
56
57impl std::fmt::Display for NotificationType {
58    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
59        match self {
60            NotificationType::ActivityMessage => write!(f, "Activity Message"),
61            NotificationType::ActivityReply => write!(f, "Activity Reply"),
62            NotificationType::Following => write!(f, "Following"),
63            NotificationType::ActivityMention => write!(f, "Activity Mention"),
64            NotificationType::ThreadCommentMention => write!(f, "Thread Comment Mention"),
65            NotificationType::Airing => write!(f, "Airing"),
66            NotificationType::ActivityLike => write!(f, "Activity Like"),
67            NotificationType::ActivityReplyLike => write!(f, "Activity Reply Like"),
68            NotificationType::ThreadLike => write!(f, "Thread Like"),
69            NotificationType::ActivityReplySubscribed => write!(f, "Activity Reply Subscribed"),
70            NotificationType::RelatedMediaAddition => write!(f, "Related Media Addition"),
71            NotificationType::MediaDataChange => write!(f, "Media Data Change"),
72            NotificationType::MediaMerge => write!(f, "Media Merge"),
73            NotificationType::MediaDeletion => write!(f, "Media Deletion"),
74        }
75    }
76}