Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scrobble #95

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions shukusai/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions shukusai/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ pub use phase::*;

mod playlist;
pub use playlist::*;

mod scrobble;
pub use scrobble::*;
46 changes: 46 additions & 0 deletions shukusai/src/state/scrobble.rs
Original file line number Diff line number Diff line change
@@ -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<SongKey, u64>);

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<SongKey, u64> {
&self.0
}
}

//---------------------------------------------------------------------------------------------------- TESTS
//#[cfg(test)]
//mod tests {
// #[test]
// fn __TEST__() {
// }
//}
Loading