From ef4c1cec446a18141c08165380795fdbdb47de0d Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sat, 16 Dec 2023 01:45:29 +0100 Subject: move assetrole struct to common --- common/src/impl.rs | 11 ++++++++++- common/src/lib.rs | 8 ++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'common/src') 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 */ -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, +} -- cgit v1.2.3-70-g09d2