aboutsummaryrefslogtreecommitdiff
path: root/common/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'common/src/lib.rs')
-rw-r--r--common/src/lib.rs52
1 files changed, 52 insertions, 0 deletions
diff --git a/common/src/lib.rs b/common/src/lib.rs
index 5387679..57b210b 100644
--- a/common/src/lib.rs
+++ b/common/src/lib.rs
@@ -67,6 +67,10 @@ pub enum ImportSource {
Tmdb {
id: u64,
},
+ Trakt {
+ kind: TraktKind,
+ id: u64,
+ },
AutoChildren {
path: Option<PathBuf>,
},
@@ -163,6 +167,7 @@ pub enum Rating {
YoutubeViews,
YoutubeLikes,
YoutubeFollowers,
+ Trakt,
}
#[derive(Debug, Clone, Deserialize, Serialize, Encode, Decode)]
@@ -188,3 +193,50 @@ pub enum AssetRole {
#[cfg_attr(feature = "rocket", field(value = "poster"))] Poster,
#[cfg_attr(feature = "rocket", field(value = "backdrop"))] Backdrop,
}
+
+#[derive(Debug, Serialize, Deserialize, Clone, Copy, Encode, Decode)]
+#[serde(rename_all = "snake_case")]
+pub enum TraktKind {
+ Movie,
+ Show,
+ Season,
+ Episode,
+ Person,
+ User,
+}
+
+impl TraktKind {
+ pub fn singular(self) -> &'static str {
+ match self {
+ TraktKind::Movie => "movie",
+ TraktKind::Show => "show",
+ TraktKind::Season => "season",
+ TraktKind::Episode => "episode",
+ TraktKind::Person => "person",
+ TraktKind::User => "user",
+ }
+ }
+ pub fn plural(self) -> &'static str {
+ match self {
+ TraktKind::Movie => "movies",
+ TraktKind::Show => "shows",
+ TraktKind::Season => "seasons",
+ TraktKind::Episode => "episodes",
+ TraktKind::Person => "people",
+ TraktKind::User => "users", // //! not used in API
+ }
+ }
+}
+impl ToString for TraktKind {
+ fn to_string(&self) -> String {
+ match self {
+ TraktKind::Movie => "Movie",
+ TraktKind::Show => "Show",
+ TraktKind::Season => "Season",
+ TraktKind::Episode => "Episode",
+ TraktKind::Person => "Person",
+ TraktKind::User => "User",
+ }
+ .to_string()
+ }
+}