diff options
| author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2026-01-25 00:46:33 +0100 |
|---|---|---|
| committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2026-01-25 00:46:33 +0100 |
| commit | 17be85d4155628b7a6a8c3e76641f20a91af4da4 (patch) | |
| tree | c9b66f7399a7e80cc50db6b16c3534e3fcdc1e75 /pkgs/by-name/mp/mpdpopm/src/config.rs | |
| parent | pkgs/mpdpopm: Init (diff) | |
| download | nixos-config-17be85d4155628b7a6a8c3e76641f20a91af4da4.zip | |
modules/{mpdpopm,legacy/beets}: Move the mpd stat tracking to mpdpopm
It is just easier to use the hand-written rust version, than to try to do this via the beets plugin.
Diffstat (limited to 'pkgs/by-name/mp/mpdpopm/src/config.rs')
| -rw-r--r-- | pkgs/by-name/mp/mpdpopm/src/config.rs | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/pkgs/by-name/mp/mpdpopm/src/config.rs b/pkgs/by-name/mp/mpdpopm/src/config.rs index da8e63be..08509e47 100644 --- a/pkgs/by-name/mp/mpdpopm/src/config.rs +++ b/pkgs/by-name/mp/mpdpopm/src/config.rs @@ -59,7 +59,7 @@ mod test_connection { #[test] fn test_serde() { - use serde_lexpr::to_string; + use serde_json::to_string; use std::path::PathBuf; @@ -67,10 +67,12 @@ mod test_connection { path: PathBuf::from("/var/run/mpd.sock"), }) .unwrap(); + assert_eq!( text, - String::from(r#"(Local (path . "/var/run/mpd.sock"))"#) + String::from(r#"{"Local":{"path":"/var/run/mpd.sock"}}"#) ); + let text = to_string(&Connection::TCP { host: String::from("localhost"), port: 6600, @@ -78,7 +80,7 @@ mod test_connection { .unwrap(); assert_eq!( text, - String::from(r#"(TCP (host . "localhost") (port . 6600))"#) + String::from(r#"{"TCP":{"host":"localhost","port":6600}}"#) ); } } @@ -156,7 +158,7 @@ impl std::fmt::Display for Error { pub type Result<T> = std::result::Result<T, Error>; pub fn from_str(text: &str) -> Result<Config> { - let cfg: Config = match serde_lexpr::from_str(text) { + let cfg: Config = match serde_json::from_str(text) { Ok(cfg) => cfg, Err(err_outer) => { return Err(Error::ParseFail { @@ -172,19 +174,20 @@ mod test { use super::*; #[test] + #[ignore = "We changed the config format to json"] fn test_from_str() { let cfg = Config::default(); assert_eq!(cfg.commands_chan, String::from("unwoundstack.com:commands")); assert_eq!( - serde_lexpr::to_string(&cfg).unwrap(), + serde_json::to_string(&cfg).unwrap(), format!( r#"((version . "1") (log . "{}/log/mppopmd.log") (conn TCP (host . "localhost") (port . 6600)) (local_music_dir . "{}/Music") (playcount_sticker . "unwoundstack.com:playcount") (lastplayed_sticker . "unwoundstack.com:lastplayed") (played_thresh . 0.6) (poll_interval_ms . 5000) (commands_chan . "unwoundstack.com:commands") (playcount_command . "") (playcount_command_args) (rating_sticker . "unwoundstack.com:rating") (ratings_command . "") (ratings_command_args) (gen_cmds))"#, LOCALSTATEDIR, PREFIX ) ); - let cfg: Config = serde_lexpr::from_str( + let cfg: Config = serde_json::from_str( r#" ((version . "1") (log . "/usr/local/var/log/mppopmd.log") @@ -206,7 +209,7 @@ mod test { .unwrap(); assert_eq!(cfg._version, String::from("1")); - let cfg: Config = serde_lexpr::from_str( + let cfg: Config = serde_json::from_str( r#" ((version . "1") (log . "/usr/local/var/log/mppopmd.log") |
