diff --git a/src-tauri/src/libs/mod.rs b/src-tauri/src/libs/mod.rs index 0e5a3d9b9..3694aa1ce 100644 --- a/src-tauri/src/libs/mod.rs +++ b/src-tauri/src/libs/mod.rs @@ -1,5 +1,8 @@ pub mod error; pub mod events; pub mod file_associations; -pub mod track; pub mod utils; + +// DB Structs +pub mod playlist; +pub mod track; diff --git a/src-tauri/src/libs/playlist.rs b/src-tauri/src/libs/playlist.rs new file mode 100644 index 000000000..a651f1d39 --- /dev/null +++ b/src-tauri/src/libs/playlist.rs @@ -0,0 +1,21 @@ +use std::path::PathBuf; + +use bonsaidb::core::schema::Collection; +use serde::{Deserialize, Serialize}; +use ts_rs::TS; + +/** ---------------------------------------------------------------------------- + * Playlist + * represent a playlist, that has a name and a list of tracks + * -------------------------------------------------------------------------- */ + +#[derive(Debug, Clone, Serialize, Deserialize, Collection, TS)] +#[collection(name = "playlists", primary_key = String)] +#[ts(export, export_to = "../../src/generated/typings/index.ts")] +pub struct Playlist { + #[natural_id] + pub _id: String, + pub name: String, + pub tracks: Vec, // vector of IDs + pub import_path: Option, // the path of the file on disk (not set for playlists created in app) +} diff --git a/src-tauri/src/plugins/database.rs b/src-tauri/src/plugins/database.rs index 88ee713bb..7edef7c4b 100644 --- a/src-tauri/src/plugins/database.rs +++ b/src-tauri/src/plugins/database.rs @@ -21,6 +21,7 @@ use ts_rs::TS; use crate::libs::error::{AnyResult, MuseeksError}; use crate::libs::events::IPCEvent; +use crate::libs::playlist::Playlist; use crate::libs::track::{get_track_from_file, get_track_id_for_path, Track}; use crate::libs::utils::{scan_dirs, TimeLogger}; @@ -270,22 +271,6 @@ impl DB { } } -/** ---------------------------------------------------------------------------- - * Playlist - * represent a playlist, that has a name and a list of tracks - * -------------------------------------------------------------------------- */ - -#[derive(Debug, Clone, Serialize, Deserialize, Collection, TS)] -#[collection(name = "playlists", primary_key = String)] -#[ts(export, export_to = "../../src/generated/typings/index.ts")] -pub struct Playlist { - #[natural_id] - pub _id: String, - pub name: String, - pub tracks: Vec, // vector of IDs - pub import_path: Option, // the path of the file on disk (not set for playlists created in app) -} - /** * Scan progress */