aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/Cargo.toml4
-rw-r--r--common/src/impl.rs8
-rw-r--r--common/src/lib.rs21
3 files changed, 17 insertions, 16 deletions
diff --git a/common/Cargo.toml b/common/Cargo.toml
index ce864eb..6bbc513 100644
--- a/common/Cargo.toml
+++ b/common/Cargo.toml
@@ -6,3 +6,7 @@ edition = "2021"
[dependencies]
serde = { version = "1.0.182", features = ["derive"] }
bincode = { version = "2.0.0-rc.3", features = ["derive"] }
+rocket = { version = "0.5.0-rc.3", optional = true }
+
+[features]
+rocket = ["dep:rocket"]
diff --git a/common/src/impl.rs b/common/src/impl.rs
index d7759af..55364ab 100644
--- a/common/src/impl.rs
+++ b/common/src/impl.rs
@@ -3,7 +3,7 @@
which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
Copyright (C) 2023 metamuffin <metamuffin.org>
*/
-use crate::{NodeKind, SourceTrack, SourceTrackKind};
+use crate::{SourceTrack, SourceTrackKind};
impl SourceTrackKind {
pub fn letter(&self) -> char {
@@ -34,9 +34,3 @@ impl std::fmt::Display for SourceTrack {
))
}
}
-
-impl Default for NodeKind {
- fn default() -> Self {
- Self::Collection
- }
-}
diff --git a/common/src/lib.rs b/common/src/lib.rs
index a96df9e..9d5a31e 100644
--- a/common/src/lib.rs
+++ b/common/src/lib.rs
@@ -7,6 +7,7 @@ pub mod config;
pub mod r#impl;
use bincode::{Decode, Encode};
+use rocket::{FromFormField, UriDisplayQuery};
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
@@ -57,17 +58,19 @@ pub enum AssetLocation {
Assets(PathBuf),
}
-#[derive(Debug, Clone, Deserialize, Serialize)]
+#[rustfmt::skip]
+#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq, Default)]
+#[cfg_attr(feature = "rocket", derive(FromFormField, UriDisplayQuery))]
#[serde(rename_all = "snake_case")]
pub enum NodeKind {
- Movie,
- Video,
- Collection,
- Channel,
- Show,
- Series,
- Season,
- Episode,
+ #[cfg_attr(feature = "rocket", field(value = "movie"))] #[default] Movie,
+ #[cfg_attr(feature = "rocket", field(value = "video"))] Video,
+ #[cfg_attr(feature = "rocket", field(value = "collection"))] Collection,
+ #[cfg_attr(feature = "rocket", field(value = "channel"))] Channel,
+ #[cfg_attr(feature = "rocket", field(value = "show"))] Show,
+ #[cfg_attr(feature = "rocket", field(value = "series"))] Series,
+ #[cfg_attr(feature = "rocket", field(value = "season"))] Season,
+ #[cfg_attr(feature = "rocket", field(value = "episode"))] Episode,
}
#[derive(Debug, Clone, Deserialize, Serialize)]