aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/src/impl.rs11
-rw-r--r--common/src/lib.rs8
2 files changed, 18 insertions, 1 deletions
diff --git a/common/src/impl.rs b/common/src/impl.rs
index 55364ab..ff2ce22 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::{SourceTrack, SourceTrackKind};
+use crate::{AssetRole, SourceTrack, SourceTrackKind};
impl SourceTrackKind {
pub fn letter(&self) -> char {
@@ -15,6 +15,15 @@ impl SourceTrackKind {
}
}
+impl AssetRole {
+ pub fn as_str(&self) -> &'static str {
+ match self {
+ AssetRole::Poster => "poster",
+ AssetRole::Backdrop => "backdrop",
+ }
+ }
+}
+
impl std::fmt::Display for SourceTrack {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let kspec = match &self.kind {
diff --git a/common/src/lib.rs b/common/src/lib.rs
index 8292e87..1a08750 100644
--- a/common/src/lib.rs
+++ b/common/src/lib.rs
@@ -147,3 +147,11 @@ pub enum SourceTrackKind {
},
Subtitles,
}
+
+#[rustfmt::skip]
+#[derive(Debug, Clone, Copy)]
+#[cfg_attr(feature = "rocket", derive(FromFormField, UriDisplayQuery))]
+pub enum AssetRole {
+ #[cfg_attr(feature = "rocket", field(value = "poster"))] Poster,
+ #[cfg_attr(feature = "rocket", field(value = "backdrop"))] Backdrop,
+}