aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/src/lib.rs54
1 files changed, 37 insertions, 17 deletions
diff --git a/common/src/lib.rs b/common/src/lib.rs
index c678cdb..2e80744 100644
--- a/common/src/lib.rs
+++ b/common/src/lib.rs
@@ -3,26 +3,44 @@ pub mod r#impl;
use bincode::{Decode, Encode};
use serde::{Deserialize, Serialize};
-use std::{collections::BTreeMap, path::PathBuf, ops::Deref};
+use std::{
+ collections::BTreeMap,
+ ops::{Deref, DerefMut},
+ path::PathBuf,
+};
#[derive(Debug, Clone, Deserialize, Serialize)]
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>,
+ #[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,
+ pub common: CommmonInfo,
#[serde(default)]
pub kind: DirectoryKind,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
+pub struct ItemInfo {
+ #[serde(flatten)]
+ pub common: CommmonInfo,
+ pub duration: f64, // in seconds
+ pub tracks: BTreeMap<usize, SourceTrack>,
+}
+
+
+
+#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum DirectoryKind {
Folder,
@@ -37,14 +55,6 @@ impl Default for DirectoryKind {
}
#[derive(Debug, Clone, Deserialize, Serialize)]
-pub struct ItemInfo {
- #[serde(flatten)]
- pub commmon: CommmonInfo,
- pub duration: f64, // in seconds
- pub tracks: BTreeMap<usize, SourceTrack>,
-}
-
-#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct SourceTrack {
pub path: PathBuf,
pub track_number: u64,
@@ -87,12 +97,22 @@ pub struct BlockIndex {
impl Deref for ItemInfo {
type Target = CommmonInfo;
fn deref(&self) -> &Self::Target {
- &self.commmon
+ &self.common
}
}
impl Deref for DirectoryInfo {
type Target = CommmonInfo;
fn deref(&self) -> &Self::Target {
- &self.commmon
+ &self.common
+ }
+}
+impl DerefMut for ItemInfo {
+ fn deref_mut(&mut self) -> &mut Self::Target {
+ &mut self.common
}
-} \ No newline at end of file
+}
+impl DerefMut for DirectoryInfo {
+ fn deref_mut(&mut self) -> &mut Self::Target {
+ &mut self.common
+ }
+}