diff options
| author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2026-01-25 17:14:31 +0100 |
|---|---|---|
| committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2026-01-25 17:14:31 +0100 |
| commit | 218f0c418e71fea27e6a3045aab66e85726426c7 (patch) | |
| tree | 90f9928927a7f0853f71d89f35247e6866309a44 /pkgs/by-name/mp/mpdpopm/src/storage/mod.rs | |
| parent | modules/river/keymap: Provide access to rate songs, bad/good (diff) | |
| download | nixos-config-218f0c418e71fea27e6a3045aab66e85726426c7.zip | |
pkgs/mpdpopm: Make the rating centered around 0 (i.e. a i8 instead of u8)
This allows us to correctly track "negative" ratings, when the user specifies `rating decr` multiple times.
Diffstat (limited to 'pkgs/by-name/mp/mpdpopm/src/storage/mod.rs')
| -rw-r--r-- | pkgs/by-name/mp/mpdpopm/src/storage/mod.rs | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/pkgs/by-name/mp/mpdpopm/src/storage/mod.rs b/pkgs/by-name/mp/mpdpopm/src/storage/mod.rs index 325b633a..d64f17c1 100644 --- a/pkgs/by-name/mp/mpdpopm/src/storage/mod.rs +++ b/pkgs/by-name/mp/mpdpopm/src/storage/mod.rs @@ -16,10 +16,6 @@ pub enum Error { source: crate::clients::Error, back: Backtrace, }, - Rating { - source: crate::ratings::Error, - back: Backtrace, - }, } impl std::fmt::Display for Error { @@ -31,7 +27,6 @@ impl std::fmt::Display for Error { write!(f, "Couldn't get system time: {}", source) } Error::Client { source, back: _ } => write!(f, "Client error: {}", source), - Error::Rating { source, back: _ } => write!(f, "Rating error: {}", source), } } } @@ -93,7 +88,10 @@ pub mod play_count { #[tokio::test] async fn pc_smoke() { let mock = Box::new(Mock::new(&[ - ("sticker get song a unwoundstack.com:playcount", "sticker: unwoundstack.com:playcount=11\nOK\n"), + ( + "sticker get song a unwoundstack.com:playcount", + "sticker: unwoundstack.com:playcount=11\nOK\n", + ), ( "sticker get song a unwoundstack.com:playcount", "ACK [50@0] {sticker} no such sticker\n", @@ -188,9 +186,9 @@ pub mod rating_count { pub const STICKER: &str = "unwoundstack.com:ratings_count"; /// Retrieve the rating count for a track - pub async fn get(client: &mut Client, file: &str) -> Result<Option<u8>> { + pub async fn get(client: &mut Client, file: &str) -> Result<Option<i8>> { client - .get_sticker::<u8>(file, STICKER) + .get_sticker::<i8>(file, STICKER) .await .map_err(|err| Error::Client { source: err, @@ -199,7 +197,7 @@ pub mod rating_count { } /// Set the rating count for a track - pub async fn set(client: &mut Client, file: &str, rating_count: u8) -> Result<()> { + pub async fn set(client: &mut Client, file: &str, rating_count: i8) -> Result<()> { client .set_sticker(file, STICKER, &format!("{}", rating_count)) .await |
