rust_anilist/models/
status.rs

1// SPDX-License-Identifier: MIT
2// Copyright (c) 2022-2025 Andriel Ferreira <https://github.com/AndrielFR>
3
4//! This module contains the `Status` enum.
5
6use serde::{Deserialize, Serialize};
7
8/// Represents the status of a media.
9#[derive(Debug, Default, Clone, Eq, Hash, PartialEq, Deserialize, Serialize)]
10#[serde(rename_all(deserialize = "SCREAMING_SNAKE_CASE"))]
11pub enum Status {
12    /// The media is finished.
13    Finished,
14    /// The media is currently releasing.
15    Releasing,
16    /// The media is not yet released.
17    #[default]
18    NotYetReleased,
19    /// The media has been cancelled.
20    Cancelled,
21    /// The media is on hiatus.
22    Hiatus,
23    /// The media is currently ongoing.
24    Current,
25    /// The media is planned for future release.
26    Planning,
27    /// The media is completed.
28    Completed,
29    /// The media has been dropped.
30    Dropped,
31    /// The media is paused.
32    Paused,
33    /// The media is repeating.
34    Repeating,
35}
36
37impl Status {
38    /// Returns a summary of the status.
39    pub fn summary(&self) -> &str {
40        match self {
41            Status::Finished => "Has completed and is no longer being updated.",
42            Status::Releasing => "Currently releasing.",
43            Status::NotYetReleased => "To be released in the future.",
44            Status::Cancelled => "Ended before the work could be completed.",
45            Status::Hiatus => "Currently paused with the intention of resuming in the future.",
46            Status::Current => "Currently being updated.",
47            Status::Planning => "Planned for future release.",
48            Status::Completed => "Has completed and is no longer being updated.",
49            Status::Dropped => {
50                "No longer being updated due to a lack of interest or other reasons."
51            }
52            Status::Paused => "Currently paused.",
53            Status::Repeating => "Repeating the same content.",
54        }
55    }
56}
57
58impl std::fmt::Display for Status {
59    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
60        match self {
61            Status::Finished => write!(f, "Finished"),
62            Status::Releasing => write!(f, "Releasing"),
63            Status::NotYetReleased => write!(f, "Not Yet Released"),
64            Status::Cancelled => write!(f, "Cancelled"),
65            Status::Hiatus => write!(f, "Hiatus"),
66            Status::Current => write!(f, "Current"),
67            Status::Planning => write!(f, "Planning"),
68            Status::Completed => write!(f, "Completed"),
69            Status::Dropped => write!(f, "Dropped"),
70            Status::Paused => write!(f, "Paused"),
71            Status::Repeating => write!(f, "Repeating"),
72        }
73    }
74}