aboutsummaryrefslogtreecommitdiff
path: root/common/src
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2023-06-14 20:38:19 +0200
committermetamuffin <metamuffin@disroot.org>2023-06-14 20:38:19 +0200
commit7cc616e965b4a4eb5a8c759c7230f9d8d01821c0 (patch)
treea6f13f69c6e3035bdbcc2bb87f6de66cb98d7911 /common/src
parent90fb37475efa3269bfc7313457e25489193c882c (diff)
downloadjellything-7cc616e965b4a4eb5a8c759c7230f9d8d01821c0.tar
jellything-7cc616e965b4a4eb5a8c759c7230f9d8d01821c0.tar.bz2
jellything-7cc616e965b4a4eb5a8c759c7230f9d8d01821c0.tar.zst
generalize share props between item and dir
Diffstat (limited to 'common/src')
-rw-r--r--common/src/lib.rs36
1 files changed, 27 insertions, 9 deletions
diff --git a/common/src/lib.rs b/common/src/lib.rs
index 47015ff..c678cdb 100644
--- a/common/src/lib.rs
+++ b/common/src/lib.rs
@@ -3,13 +3,21 @@ pub mod r#impl;
use bincode::{Decode, Encode};
use serde::{Deserialize, Serialize};
-use std::{collections::BTreeMap, path::PathBuf};
+use std::{collections::BTreeMap, path::PathBuf, ops::Deref};
#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct DirectoryInfo {
- pub name: String,
- pub banner: Option<PathBuf>,
+pub struct CommmonInfo {
+ pub title: String,
+ #[serde(default)] pub tagline: Option<String>,
+ #[serde(default)] pub description: Option<String>,
+ #[serde(default)] pub poster: Option<PathBuf>,
+ #[serde(default)] pub backdrop: Option<PathBuf>,
+}
+#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct DirectoryInfo {
+ #[serde(flatten)]
+ pub commmon: CommmonInfo,
#[serde(default)]
pub kind: DirectoryKind,
}
@@ -30,12 +38,9 @@ impl Default for DirectoryKind {
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct ItemInfo {
- pub title: String,
+ #[serde(flatten)]
+ pub commmon: CommmonInfo,
pub duration: f64, // in seconds
- pub description_head: String,
- pub description: String,
- pub poster: Option<PathBuf>,
- pub backdrop: Option<PathBuf>,
pub tracks: BTreeMap<usize, SourceTrack>,
}
@@ -78,3 +83,16 @@ pub struct BlockIndex {
pub source_off: usize,
pub size: usize,
}
+
+impl Deref for ItemInfo {
+ type Target = CommmonInfo;
+ fn deref(&self) -> &Self::Target {
+ &self.commmon
+ }
+}
+impl Deref for DirectoryInfo {
+ type Target = CommmonInfo;
+ fn deref(&self) -> &Self::Target {
+ &self.commmon
+ }
+} \ No newline at end of file