diff --git a/shukusai/src/constants.rs b/shukusai/src/constants.rs index 1f0868b6..fc53ba23 100644 --- a/shukusai/src/constants.rs +++ b/shukusai/src/constants.rs @@ -147,6 +147,9 @@ pub const AUDIO_VERSION: u8 = 0; /// Current major version of the [`Playlists`] pub const PLAYLIST_VERSION: u8 = 0; +/// Current major version of the [`Scrobble`] +pub const SCROBBLE_VERSION: u8 = 0; + #[cfg(target_os = "windows")] #[cfg(target_arch = "x86_64")] /// OS + Arch diff --git a/shukusai/src/state/mod.rs b/shukusai/src/state/mod.rs index e2c39e2b..e1828a5c 100644 --- a/shukusai/src/state/mod.rs +++ b/shukusai/src/state/mod.rs @@ -12,3 +12,6 @@ pub use phase::*; mod playlist; pub use playlist::*; + +mod scrobble; +pub use scrobble::*; diff --git a/shukusai/src/state/scrobble.rs b/shukusai/src/state/scrobble.rs new file mode 100644 index 00000000..40605dae --- /dev/null +++ b/shukusai/src/state/scrobble.rs @@ -0,0 +1,46 @@ +//---------------------------------------------------------------------------------------------------- Use +use crate::{ + collection::{Album, AlbumKey, Artist, ArtistKey, Collection, Song, SongKey}, + constants::{FESTIVAL, FRONTEND_SUB_DIR, HEADER, SCROBBLE_VERSION, STATE_SUB_DIR}, +}; +use bincode::{Decode, Encode}; +use serde::{Deserialize, Serialize}; +use std::collections::BTreeMap; +use std::sync::Arc; + +//---------------------------------------------------------------------------------------------------- Scrobble +disk::bincode2!( + Scrobble, + disk::Dir::Data, + FESTIVAL, + formatcp!("{FRONTEND_SUB_DIR}/{STATE_SUB_DIR}"), + "scrobble", + HEADER, + SCROBBLE_VERSION +); +/// TODO +// song seconds +// v v +pub struct Scrobble(BTreeMap); + +impl Scrobble { + pub(crate) fn new(song_key_max: usize) -> Self { + Self( + (0..song_key_max) + .map(|key| (SongKey::from(key), 0)) + .collect(), + ) + } + + pub(crate) fn inner(&self) -> &BTreeMap { + &self.0 + } +} + +//---------------------------------------------------------------------------------------------------- TESTS +//#[cfg(test)] +//mod tests { +// #[test] +// fn __TEST__() { +// } +//}