Compare commits
5 Commits
db-selecti
...
deduplicat
Author | SHA1 | Date | |
---|---|---|---|
e469a8eb3c
|
|||
5a5870d7de
|
|||
e5303954c5
|
|||
c95d39a9ec
|
|||
e910d29aa4
|
Cargo.lockCargo.tomlflake.lockrustfmt.tomlrequest.rsserver.rs
src
commands
client_to_client
connection_settings
protocol.rsprotocol_all.rsprotocol_available.rsprotocol_clear.rsprotocol_disable.rsprotocol_enable.rstag_types.rstag_types_all.rstag_types_available.rstag_types_clear.rstag_types_disable.rstag_types_enable.rstag_types_reset.rs
mounts_and_neighbors
music_database
albumart.rscount.rsgetfingerprint.rslist.rsreadcomments.rsreadpicture.rsrescan.rssearchcount.rsupdate.rs
partition_commands
playback_options
querying_mpd_status
queue
addid.rsaddtagid.rscleartagid.rsdelete.rsdeleteid.rsmove_.rsmoveid.rsplaylist.rsplaylistfind.rsplaylistid.rsplaylistinfo.rsplaylistsearch.rsplchanges.rsplchangesposid.rsprio.rsprioid.rsrangeid.rsshuffle.rsswap.rsswapid.rs
reflection
stickers
stored_playlists
30
Cargo.lock
generated
30
Cargo.lock
generated
@ -1,6 +1,6 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 3
|
version = 4
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "diff"
|
name = "diff"
|
||||||
@ -19,9 +19,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "indoc"
|
name = "indoc"
|
||||||
version = "2.0.5"
|
version = "2.0.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5"
|
checksum = "f4c7245a08504955605670dbf141fceab975f15ca21570696aebe9d2e71576bd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pretty_assertions"
|
name = "pretty_assertions"
|
||||||
@ -35,36 +35,36 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.88"
|
version = "1.0.95"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7c3a7fc5db1e57d5a779a352c8cdb57b29aa4c40cc69c3a68a7fedc815fbf2f9"
|
checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quote"
|
name = "quote"
|
||||||
version = "1.0.37"
|
version = "1.0.40"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
|
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.210"
|
version = "1.0.219"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a"
|
checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.210"
|
version = "1.0.219"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f"
|
checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@ -73,9 +73,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "2.0.82"
|
version = "2.0.101"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "83540f837a8afc019423a8edb95b52a8effe46957ee402287f4292fae35be021"
|
checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@ -84,9 +84,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-ident"
|
name = "unicode-ident"
|
||||||
version = "1.0.13"
|
version = "1.0.18"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe"
|
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "yansi"
|
name = "yansi"
|
||||||
|
@ -7,8 +7,8 @@ authors = [
|
|||||||
description = "A rust implementation of the mpd protocol, both client and serverside"
|
description = "A rust implementation of the mpd protocol, both client and serverside"
|
||||||
repository = "https://git.pvv.ntnu.no/Grzegorz/empidee"
|
repository = "https://git.pvv.ntnu.no/Grzegorz/empidee"
|
||||||
documentation = "https://pages.pvv.ntnu.no/Grzegorz/empidee/main/docs/empidee/"
|
documentation = "https://pages.pvv.ntnu.no/Grzegorz/empidee/main/docs/empidee/"
|
||||||
edition = "2021"
|
edition = "2024"
|
||||||
rust-version = "1.83.0"
|
rust-version = "1.85.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde = { version = "1.0.210", features = ["derive"] }
|
serde = { version = "1.0.210", features = ["derive"] }
|
||||||
|
12
flake.lock
generated
12
flake.lock
generated
@ -2,11 +2,11 @@
|
|||||||
"nodes": {
|
"nodes": {
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1739866667,
|
"lastModified": 1746461020,
|
||||||
"narHash": "sha256-EO1ygNKZlsAC9avfcwHkKGMsmipUk1Uc0TbrEZpkn64=",
|
"narHash": "sha256-7+pG1I9jvxNlmln4YgnlW4o+w0TZX24k688mibiFDUE=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "73cf49b8ad837ade2de76f87eb53fc85ed5d4680",
|
"rev": "3730d8a308f94996a9ba7c7138ede69c1b9ac4ae",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -29,11 +29,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1740277845,
|
"lastModified": 1746585402,
|
||||||
"narHash": "sha256-NNU0CdiaSbAeZ8tpDG4aFi9qtcdlItRvk8Xns9oBrVU=",
|
"narHash": "sha256-Pf+ufu6bYNA1+KQKHnGMNEfTwpD9ZIcAeLoE2yPWIP0=",
|
||||||
"owner": "oxalica",
|
"owner": "oxalica",
|
||||||
"repo": "rust-overlay",
|
"repo": "rust-overlay",
|
||||||
"rev": "f933070c29f9c1c5457447a51903f27f76ebb519",
|
"rev": "72dd969389583664f87aa348b3458f2813693617",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
1
rustfmt.toml
Normal file
1
rustfmt.toml
Normal file
@ -0,0 +1 @@
|
|||||||
|
style_edition = "2024"
|
@ -1,8 +1,8 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::commands::{
|
use crate::commands::{
|
||||||
expect_property_type, Command, Request, RequestParserResult, ResponseAttributes,
|
Command, Request, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
ResponseParserError,
|
expect_property_type,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Channels;
|
pub struct Channels;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::commands::{
|
use crate::commands::{
|
||||||
expect_property_type, Command, Request, RequestParserResult, ResponseAttributes,
|
Command, Request, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
ResponseParserError,
|
expect_property_type,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct ReadMessages;
|
pub struct ReadMessages;
|
||||||
@ -34,8 +34,12 @@ impl Command for ReadMessages {
|
|||||||
let (ckey, cvalue) = channel_message_pair[0];
|
let (ckey, cvalue) = channel_message_pair[0];
|
||||||
let (mkey, mvalue) = channel_message_pair[1];
|
let (mkey, mvalue) = channel_message_pair[1];
|
||||||
|
|
||||||
debug_assert!(ckey == "channel");
|
if ckey != "channel" {
|
||||||
debug_assert!(mkey == "message");
|
return Err(ResponseParserError::UnexpectedProperty(ckey));
|
||||||
|
}
|
||||||
|
if mkey != "message" {
|
||||||
|
return Err(ResponseParserError::UnexpectedProperty(mkey));
|
||||||
|
}
|
||||||
|
|
||||||
let channel = expect_property_type!(Some(cvalue), "channel", Text).to_string();
|
let channel = expect_property_type!(Some(cvalue), "channel", Text).to_string();
|
||||||
let message = expect_property_type!(Some(mvalue), "message", Text).to_string();
|
let message = expect_property_type!(Some(mvalue), "message", Text).to_string();
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
commands::{Command, RequestParserResult, ResponseAttributes, ResponseParserError},
|
|
||||||
Request,
|
Request,
|
||||||
|
commands::{Command, RequestParserResult, ResponseAttributes, ResponseParserError},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Protocol;
|
pub struct Protocol;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
commands::{Command, RequestParserResult, ResponseAttributes, ResponseParserError},
|
|
||||||
Request,
|
Request,
|
||||||
|
commands::{Command, RequestParserResult, ResponseAttributes, ResponseParserError},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct ProtocolAll;
|
pub struct ProtocolAll;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
commands::{Command, RequestParserResult, ResponseAttributes, ResponseParserError},
|
|
||||||
Request,
|
Request,
|
||||||
|
commands::{Command, RequestParserResult, ResponseAttributes, ResponseParserError},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct ProtocolAvailable;
|
pub struct ProtocolAvailable;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
commands::{Command, RequestParserResult, ResponseAttributes, ResponseParserError},
|
|
||||||
Request,
|
Request,
|
||||||
|
commands::{Command, RequestParserResult, ResponseAttributes, ResponseParserError},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct ProtocolClear;
|
pub struct ProtocolClear;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
|
Request,
|
||||||
commands::{
|
commands::{
|
||||||
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
},
|
},
|
||||||
Request,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct ProtocolDisable;
|
pub struct ProtocolDisable;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
|
Request,
|
||||||
commands::{
|
commands::{
|
||||||
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
},
|
},
|
||||||
Request,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct ProtocolEnable;
|
pub struct ProtocolEnable;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::commands::{
|
use crate::commands::{
|
||||||
Command, GenericResponseValue, Request, RequestParserResult, ResponseAttributes,
|
Command, Request, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
ResponseParserError,
|
expect_property_type,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct TagTypes;
|
pub struct TagTypes;
|
||||||
@ -24,16 +24,7 @@ impl Command for TagTypes {
|
|||||||
let mut tagtypes = Vec::with_capacity(parts.len());
|
let mut tagtypes = Vec::with_capacity(parts.len());
|
||||||
for (key, value) in parts.into_iter() {
|
for (key, value) in parts.into_iter() {
|
||||||
debug_assert_eq!(key, "tagtype");
|
debug_assert_eq!(key, "tagtype");
|
||||||
|
let tagtype = expect_property_type!(Some(value), "tagtype", Text).to_string();
|
||||||
let tagtype = match value {
|
|
||||||
GenericResponseValue::Text(name) => name.to_string(),
|
|
||||||
GenericResponseValue::Binary(_) => {
|
|
||||||
return Err(ResponseParserError::UnexpectedPropertyType(
|
|
||||||
"tagtype", "Binary",
|
|
||||||
))
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
tagtypes.push(tagtype);
|
tagtypes.push(tagtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
commands::{Command, RequestParserResult, ResponseAttributes, ResponseParserError},
|
|
||||||
Request,
|
Request,
|
||||||
|
commands::{Command, RequestParserResult, ResponseAttributes, ResponseParserError},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct TagTypesAll;
|
pub struct TagTypesAll;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
commands::{Command, RequestParserResult, ResponseAttributes, ResponseParserError},
|
|
||||||
Request,
|
Request,
|
||||||
|
commands::{Command, RequestParserResult, ResponseAttributes, ResponseParserError},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct TagTypesAvailable;
|
pub struct TagTypesAvailable;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
commands::{Command, RequestParserResult, ResponseAttributes, ResponseParserError},
|
|
||||||
Request,
|
Request,
|
||||||
|
commands::{Command, RequestParserResult, ResponseAttributes, ResponseParserError},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct TagTypesClear;
|
pub struct TagTypesClear;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
|
Request,
|
||||||
commands::{
|
commands::{
|
||||||
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
},
|
},
|
||||||
Request,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct TagTypesDisable;
|
pub struct TagTypesDisable;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
|
Request,
|
||||||
commands::{
|
commands::{
|
||||||
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
},
|
},
|
||||||
Request,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct TagTypesEnable;
|
pub struct TagTypesEnable;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
|
Request,
|
||||||
commands::{
|
commands::{
|
||||||
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
},
|
},
|
||||||
Request,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct TagTypesReset;
|
pub struct TagTypesReset;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
commands::{Command, RequestParserResult, ResponseAttributes, ResponseParserError},
|
|
||||||
Request,
|
Request,
|
||||||
|
commands::{Command, RequestParserResult, ResponseAttributes, ResponseParserError},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct ListMounts;
|
pub struct ListMounts;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
commands::{Command, RequestParserResult, ResponseAttributes, ResponseParserError},
|
|
||||||
Request,
|
Request,
|
||||||
|
commands::{Command, RequestParserResult, ResponseAttributes, ResponseParserError},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct ListNeighbors;
|
pub struct ListNeighbors;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
|
Request,
|
||||||
commands::{
|
commands::{
|
||||||
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
},
|
},
|
||||||
Request,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Mount;
|
pub struct Mount;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
|
Request,
|
||||||
commands::{
|
commands::{
|
||||||
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
},
|
},
|
||||||
Request,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Unmount;
|
pub struct Unmount;
|
||||||
|
@ -2,8 +2,8 @@ use std::collections::HashMap;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
commands::{
|
commands::{
|
||||||
get_and_parse_property, get_property, Command, Request, RequestParserError,
|
Command, Request, RequestParserError, RequestParserResult, ResponseAttributes,
|
||||||
RequestParserResult, ResponseAttributes, ResponseParserError,
|
ResponseParserError, get_and_parse_property, get_property,
|
||||||
},
|
},
|
||||||
common::Offset,
|
common::Offset,
|
||||||
};
|
};
|
||||||
|
@ -2,8 +2,8 @@ use std::collections::HashMap;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
commands::{
|
commands::{
|
||||||
get_and_parse_property, Command, Request, RequestParserError, RequestParserResult,
|
Command, Request, RequestParserError, RequestParserResult, ResponseAttributes,
|
||||||
ResponseAttributes, ResponseParserError,
|
ResponseParserError, get_and_parse_property,
|
||||||
},
|
},
|
||||||
filter::parse_filter,
|
filter::parse_filter,
|
||||||
};
|
};
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use crate::commands::{
|
use crate::commands::{
|
||||||
get_and_parse_property, Command, Request, RequestParserError, RequestParserResult,
|
Command, Request, RequestParserError, RequestParserResult, ResponseAttributes,
|
||||||
ResponseAttributes, ResponseParserError,
|
ResponseParserError, get_and_parse_property,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct GetFingerprint;
|
pub struct GetFingerprint;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
commands::{
|
commands::{
|
||||||
expect_property_type, Command, Request, RequestParserError, RequestParserResult,
|
Command, Request, RequestParserError, RequestParserResult, ResponseAttributes,
|
||||||
ResponseAttributes, ResponseParserError,
|
ResponseParserError, expect_property_type,
|
||||||
},
|
},
|
||||||
filter::parse_filter,
|
filter::parse_filter,
|
||||||
};
|
};
|
||||||
|
@ -2,7 +2,7 @@ use std::collections::HashMap;
|
|||||||
|
|
||||||
use crate::commands::{
|
use crate::commands::{
|
||||||
Command, GenericResponseValue, Request, RequestParserError, RequestParserResult,
|
Command, GenericResponseValue, Request, RequestParserError, RequestParserResult,
|
||||||
ResponseAttributes, ResponseParserError,
|
ResponseAttributes, ResponseParserError, expect_property_type,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct ReadComments;
|
pub struct ReadComments;
|
||||||
@ -30,10 +30,12 @@ impl Command for ReadComments {
|
|||||||
let parts: HashMap<_, _> = parts.into();
|
let parts: HashMap<_, _> = parts.into();
|
||||||
|
|
||||||
let comments = parts
|
let comments = parts
|
||||||
.iter()
|
.into_iter()
|
||||||
.map(|(k, v)| match v {
|
.map(|(k, v)| {
|
||||||
GenericResponseValue::Text(s) => Ok((k.to_string(), s.to_string())),
|
Ok((
|
||||||
GenericResponseValue::Binary(_) => Err(ResponseParserError::SyntaxError(1, k)),
|
k.to_string(),
|
||||||
|
expect_property_type!(Some(v), k, Text).to_string(),
|
||||||
|
))
|
||||||
})
|
})
|
||||||
.collect::<Result<HashMap<_, _>, ResponseParserError>>()?;
|
.collect::<Result<HashMap<_, _>, ResponseParserError>>()?;
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@ use std::collections::HashMap;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
commands::{
|
commands::{
|
||||||
get_and_parse_property, get_optional_property, get_property, Command, Request,
|
Command, Request, RequestParserError, RequestParserResult, ResponseAttributes,
|
||||||
RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
ResponseParserError, get_and_parse_property, get_optional_property, get_property,
|
||||||
},
|
},
|
||||||
common::Offset,
|
common::Offset,
|
||||||
};
|
};
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use crate::commands::{
|
use crate::commands::{
|
||||||
get_and_parse_property, Command, Request, RequestParserResult, ResponseAttributes,
|
Command, Request, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
ResponseParserError,
|
get_and_parse_property,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Rescan;
|
pub struct Rescan;
|
||||||
|
@ -2,8 +2,8 @@ use std::collections::HashMap;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
commands::{
|
commands::{
|
||||||
get_and_parse_property, Command, Request, RequestParserError, RequestParserResult,
|
Command, Request, RequestParserError, RequestParserResult, ResponseAttributes,
|
||||||
ResponseAttributes, ResponseParserError,
|
ResponseParserError, get_and_parse_property,
|
||||||
},
|
},
|
||||||
filter::parse_filter,
|
filter::parse_filter,
|
||||||
};
|
};
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use crate::commands::{
|
use crate::commands::{
|
||||||
get_and_parse_property, Command, Request, RequestParserResult, ResponseAttributes,
|
Command, Request, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
ResponseParserError,
|
get_and_parse_property,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Update;
|
pub struct Update;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::commands::{
|
use crate::commands::{
|
||||||
expect_property_type, Command, Request, RequestParserResult, ResponseAttributes,
|
Command, Request, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
ResponseParserError,
|
expect_property_type,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct ListPartitions;
|
pub struct ListPartitions;
|
||||||
|
@ -2,8 +2,8 @@ use std::collections::HashMap;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
commands::{
|
commands::{
|
||||||
get_and_parse_property, Command, Request, RequestParserResult, ResponseAttributes,
|
Command, Request, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
ResponseParserError,
|
get_and_parse_property,
|
||||||
},
|
},
|
||||||
common::VolumeValue,
|
common::VolumeValue,
|
||||||
};
|
};
|
||||||
|
@ -4,8 +4,8 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
commands::{
|
commands::{
|
||||||
get_property, Command, Request, RequestParserResult, ResponseAttributes,
|
Command, Request, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
ResponseParserError,
|
get_property,
|
||||||
},
|
},
|
||||||
common::ReplayGainModeMode,
|
common::ReplayGainModeMode,
|
||||||
};
|
};
|
||||||
|
@ -3,8 +3,8 @@ use std::collections::HashMap;
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::commands::{
|
use crate::commands::{
|
||||||
get_and_parse_optional_property, get_and_parse_property, Command, Request, RequestParserResult,
|
Command, Request, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
ResponseAttributes, ResponseParserError,
|
get_and_parse_optional_property, get_and_parse_property,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Stats;
|
pub struct Stats;
|
||||||
|
@ -6,9 +6,9 @@ use serde::{Deserialize, Serialize};
|
|||||||
use crate::common::{Audio, BoolOrOneshot, SongId, SongPosition};
|
use crate::common::{Audio, BoolOrOneshot, SongId, SongPosition};
|
||||||
|
|
||||||
use crate::commands::{
|
use crate::commands::{
|
||||||
get_and_parse_optional_property, get_and_parse_property, get_optional_property, get_property,
|
|
||||||
Command, GenericResponseValue, Request, RequestParserResult, ResponseAttributes,
|
Command, GenericResponseValue, Request, RequestParserResult, ResponseAttributes,
|
||||||
ResponseParserError,
|
ResponseParserError, get_and_parse_optional_property, get_and_parse_property,
|
||||||
|
get_optional_property, get_property,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
commands::{
|
commands::{
|
||||||
get_next_and_parse_property, Command, Request, RequestParserError, RequestParserResult,
|
Command, Request, RequestParserError, RequestParserResult, ResponseAttributes,
|
||||||
ResponseAttributes, ResponseParserError,
|
ResponseParserError, get_next_and_parse_property,
|
||||||
},
|
},
|
||||||
common::{SongId, SongPosition},
|
common::{SongId, SongPosition},
|
||||||
};
|
};
|
||||||
@ -40,8 +40,15 @@ impl Command for AddId {
|
|||||||
) -> Result<Self::Response, ResponseParserError> {
|
) -> Result<Self::Response, ResponseParserError> {
|
||||||
let parts: Vec<_> = parts.into();
|
let parts: Vec<_> = parts.into();
|
||||||
let mut iter = parts.into_iter();
|
let mut iter = parts.into_iter();
|
||||||
|
|
||||||
let (key, id) = get_next_and_parse_property!(iter, Text);
|
let (key, id) = get_next_and_parse_property!(iter, Text);
|
||||||
debug_assert!(key == "Id");
|
|
||||||
|
if key != "Id" {
|
||||||
|
return Err(ResponseParserError::UnexpectedProperty(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
debug_assert!(iter.next().is_none());
|
||||||
|
|
||||||
Ok(AddIdResponse { id })
|
Ok(AddIdResponse { id })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
|
Request,
|
||||||
commands::{
|
commands::{
|
||||||
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
},
|
},
|
||||||
Request,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct AddTagId;
|
pub struct AddTagId;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
|
Request,
|
||||||
commands::{
|
commands::{
|
||||||
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
},
|
},
|
||||||
Request,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct ClearTagId;
|
pub struct ClearTagId;
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
Request,
|
||||||
commands::{
|
commands::{
|
||||||
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
},
|
},
|
||||||
common::OneOrRange,
|
common::OneOrRange,
|
||||||
Request,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Delete;
|
pub struct Delete;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
|
Request,
|
||||||
commands::{
|
commands::{
|
||||||
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
},
|
},
|
||||||
Request,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct DeleteId;
|
pub struct DeleteId;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
|
Request,
|
||||||
commands::{
|
commands::{
|
||||||
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
},
|
},
|
||||||
Request,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Move;
|
pub struct Move;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
|
Request,
|
||||||
commands::{
|
commands::{
|
||||||
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
},
|
},
|
||||||
Request,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct MoveId;
|
pub struct MoveId;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
commands::{Command, RequestParserResult, ResponseAttributes, ResponseParserError},
|
|
||||||
Request,
|
Request,
|
||||||
|
commands::{Command, RequestParserResult, ResponseAttributes, ResponseParserError},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Playlist;
|
pub struct Playlist;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
|
Request,
|
||||||
commands::{
|
commands::{
|
||||||
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
},
|
},
|
||||||
filter::parse_filter,
|
filter::parse_filter,
|
||||||
Request,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct PlaylistFind;
|
pub struct PlaylistFind;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
|
Request,
|
||||||
commands::{
|
commands::{
|
||||||
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
},
|
},
|
||||||
Request,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct PlaylistId;
|
pub struct PlaylistId;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
|
Request,
|
||||||
commands::{
|
commands::{
|
||||||
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
},
|
},
|
||||||
Request,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct PlaylistInfo;
|
pub struct PlaylistInfo;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
|
Request,
|
||||||
commands::{
|
commands::{
|
||||||
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
},
|
},
|
||||||
filter::parse_filter,
|
filter::parse_filter,
|
||||||
Request,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct PlaylistSearch;
|
pub struct PlaylistSearch;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
|
Request,
|
||||||
commands::{
|
commands::{
|
||||||
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
},
|
},
|
||||||
Request,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct PlChanges;
|
pub struct PlChanges;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
|
Request,
|
||||||
commands::{
|
commands::{
|
||||||
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
},
|
},
|
||||||
Request,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct PlChangesPosId;
|
pub struct PlChangesPosId;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
|
Request,
|
||||||
commands::{
|
commands::{
|
||||||
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
},
|
},
|
||||||
Request,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Prio;
|
pub struct Prio;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
|
Request,
|
||||||
commands::{
|
commands::{
|
||||||
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
},
|
},
|
||||||
Request,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct PrioId;
|
pub struct PrioId;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
|
Request,
|
||||||
commands::{
|
commands::{
|
||||||
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
},
|
},
|
||||||
Request,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct RangeId;
|
pub struct RangeId;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
|
Request,
|
||||||
commands::{
|
commands::{
|
||||||
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
},
|
},
|
||||||
Request,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Shuffle;
|
pub struct Shuffle;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
|
Request,
|
||||||
commands::{
|
commands::{
|
||||||
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
},
|
},
|
||||||
Request,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Swap;
|
pub struct Swap;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
|
Request,
|
||||||
commands::{
|
commands::{
|
||||||
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
},
|
},
|
||||||
Request,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct SwapId;
|
pub struct SwapId;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::commands::{
|
use crate::commands::{
|
||||||
Command, GenericResponseValue, Request, RequestParserResult, ResponseAttributes,
|
Command, Request, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
ResponseParserError,
|
expect_property_type,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Commands;
|
pub struct Commands;
|
||||||
@ -25,14 +25,7 @@ impl Command for Commands {
|
|||||||
if key != "command" {
|
if key != "command" {
|
||||||
return Err(ResponseParserError::UnexpectedProperty(key));
|
return Err(ResponseParserError::UnexpectedProperty(key));
|
||||||
}
|
}
|
||||||
let value = match value {
|
let value = expect_property_type!(Some(value), "command", Text);
|
||||||
GenericResponseValue::Text(value) => value,
|
|
||||||
GenericResponseValue::Binary(_) => {
|
|
||||||
return Err(ResponseParserError::UnexpectedPropertyType(
|
|
||||||
"handler", "Binary",
|
|
||||||
))
|
|
||||||
}
|
|
||||||
};
|
|
||||||
result.push(value.to_string());
|
result.push(value.to_string());
|
||||||
}
|
}
|
||||||
Ok(result)
|
Ok(result)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use crate::commands::{
|
use crate::commands::{
|
||||||
get_and_parse_property, get_property, Command, Request, RequestParserResult,
|
Command, Request, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
ResponseAttributes, ResponseParserError,
|
get_and_parse_property, get_property,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Config;
|
pub struct Config;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::commands::{
|
use crate::commands::{
|
||||||
Command, GenericResponseValue, Request, RequestParserResult, ResponseAttributes,
|
Command, Request, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
ResponseParserError,
|
expect_property_type,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct NotCommands;
|
pub struct NotCommands;
|
||||||
@ -25,14 +25,7 @@ impl Command for NotCommands {
|
|||||||
if key != "command" {
|
if key != "command" {
|
||||||
return Err(ResponseParserError::UnexpectedProperty(key));
|
return Err(ResponseParserError::UnexpectedProperty(key));
|
||||||
}
|
}
|
||||||
let value = match value {
|
let value = expect_property_type!(Some(value), "command", Text).to_string();
|
||||||
GenericResponseValue::Text(value) => value,
|
|
||||||
GenericResponseValue::Binary(_) => {
|
|
||||||
return Err(ResponseParserError::UnexpectedPropertyType(
|
|
||||||
"handler", "Binary",
|
|
||||||
))
|
|
||||||
}
|
|
||||||
};
|
|
||||||
result.push(value.to_string());
|
result.push(value.to_string());
|
||||||
}
|
}
|
||||||
Ok(result)
|
Ok(result)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::commands::{
|
use crate::commands::{
|
||||||
Command, GenericResponseValue, Request, RequestParserResult, ResponseAttributes,
|
Command, Request, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
ResponseParserError,
|
expect_property_type,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct UrlHandlers;
|
pub struct UrlHandlers;
|
||||||
@ -25,14 +25,7 @@ impl Command for UrlHandlers {
|
|||||||
if key != "handler" {
|
if key != "handler" {
|
||||||
return Err(ResponseParserError::UnexpectedProperty(key));
|
return Err(ResponseParserError::UnexpectedProperty(key));
|
||||||
}
|
}
|
||||||
let value = match value {
|
let value = expect_property_type!(Some(value), "handler", Text);
|
||||||
GenericResponseValue::Text(value) => value,
|
|
||||||
GenericResponseValue::Binary(_) => {
|
|
||||||
return Err(ResponseParserError::UnexpectedPropertyType(
|
|
||||||
"handler", "Binary",
|
|
||||||
))
|
|
||||||
}
|
|
||||||
};
|
|
||||||
url_handlers.push(value.to_string());
|
url_handlers.push(value.to_string());
|
||||||
}
|
}
|
||||||
Ok(url_handlers)
|
Ok(url_handlers)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::commands::{
|
use crate::commands::{
|
||||||
Command, GenericResponseValue, Request, RequestParserError, RequestParserResult,
|
Command, Request, RequestParserError, RequestParserResult, ResponseAttributes,
|
||||||
ResponseAttributes, ResponseParserError,
|
ResponseParserError, expect_property_type,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct StickerFind;
|
pub struct StickerFind;
|
||||||
@ -84,21 +84,8 @@ impl Command for StickerFind {
|
|||||||
// TODO: debug assert that this is a valid sticker type
|
// TODO: debug assert that this is a valid sticker type
|
||||||
// debug_assert!(uri.0 == "");
|
// debug_assert!(uri.0 == "");
|
||||||
|
|
||||||
let uri = match uri.1 {
|
let uri = expect_property_type!(Some(uri.1), uri.0, Text).to_string();
|
||||||
GenericResponseValue::Text(s) => s.to_string(),
|
let sticker = expect_property_type!(Some(sticker.1), sticker.0, Text);
|
||||||
GenericResponseValue::Binary(_) => {
|
|
||||||
return Err(ResponseParserError::UnexpectedPropertyType(uri.0, "Binary"))
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let sticker = match sticker.1 {
|
|
||||||
GenericResponseValue::Text(s) => s,
|
|
||||||
GenericResponseValue::Binary(_) => {
|
|
||||||
return Err(ResponseParserError::UnexpectedPropertyType(
|
|
||||||
"sticker", "Binary",
|
|
||||||
))
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// TODO: This assumes the first = is the only one.
|
// TODO: This assumes the first = is the only one.
|
||||||
// See: https://github.com/MusicPlayerDaemon/MPD/issues/2166
|
// See: https://github.com/MusicPlayerDaemon/MPD/issues/2166
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::commands::{
|
use crate::commands::{
|
||||||
get_next_property, Command, Request, RequestParserError, RequestParserResult,
|
Command, Request, RequestParserError, RequestParserResult, ResponseAttributes,
|
||||||
ResponseAttributes, ResponseParserError,
|
ResponseParserError, get_next_property,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct StickerGet;
|
pub struct StickerGet;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use crate::commands::{
|
use crate::commands::{
|
||||||
Command, GenericResponseValue, Request, RequestParserError, RequestParserResult,
|
Command, Request, RequestParserError, RequestParserResult, ResponseAttributes,
|
||||||
ResponseAttributes, ResponseParserError,
|
ResponseParserError, expect_property_type,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct StickerList;
|
pub struct StickerList;
|
||||||
@ -37,12 +37,7 @@ impl Command for StickerList {
|
|||||||
|
|
||||||
let result = parts
|
let result = parts
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(_, v)| match v {
|
.map(|(k, v)| Ok(expect_property_type!(Some(v), k, Text)))
|
||||||
GenericResponseValue::Text(value) => Ok(value),
|
|
||||||
GenericResponseValue::Binary(_) => Err(
|
|
||||||
ResponseParserError::UnexpectedPropertyType("sticker", "Binary"),
|
|
||||||
),
|
|
||||||
})
|
|
||||||
.collect::<Result<Vec<_>, ResponseParserError>>()?;
|
.collect::<Result<Vec<_>, ResponseParserError>>()?;
|
||||||
|
|
||||||
result
|
result
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::commands::{
|
use crate::commands::{
|
||||||
expect_property_type, Command, Request, RequestParserResult, ResponseAttributes,
|
Command, Request, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
ResponseParserError,
|
expect_property_type,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct StickerNames;
|
pub struct StickerNames;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use crate::commands::{
|
use crate::commands::{
|
||||||
Command, GenericResponseValue, Request, RequestParserResult, ResponseAttributes,
|
Command, Request, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
ResponseParserError,
|
expect_property_type,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct StickerNamesTypes;
|
pub struct StickerNamesTypes;
|
||||||
@ -34,23 +34,8 @@ impl Command for StickerNamesTypes {
|
|||||||
debug_assert!(name_key == "name");
|
debug_assert!(name_key == "name");
|
||||||
debug_assert!(type_key == "type");
|
debug_assert!(type_key == "type");
|
||||||
|
|
||||||
let name = match name_value {
|
let name = expect_property_type!(Some(name_value), name_key, Text).to_string();
|
||||||
GenericResponseValue::Text(s) => s.to_string(),
|
let sticker_type = expect_property_type!(Some(type_value), type_key, Text).to_string();
|
||||||
GenericResponseValue::Binary(_) => {
|
|
||||||
return Err(ResponseParserError::UnexpectedPropertyType(
|
|
||||||
"name", "Binary",
|
|
||||||
))
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let sticker_type = match type_value {
|
|
||||||
GenericResponseValue::Text(s) => s.to_string(),
|
|
||||||
GenericResponseValue::Binary(_) => {
|
|
||||||
return Err(ResponseParserError::UnexpectedPropertyType(
|
|
||||||
"type", "Binary",
|
|
||||||
))
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
result
|
result
|
||||||
.entry(name)
|
.entry(name)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::commands::{
|
use crate::commands::{
|
||||||
expect_property_type, Command, Request, RequestParserResult, ResponseAttributes,
|
Command, Request, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||||
ResponseParserError,
|
expect_property_type,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct StickerTypes;
|
pub struct StickerTypes;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
commands::{
|
commands::{
|
||||||
Command, GenericResponseValue, Request, RequestParserError, RequestParserResult,
|
Command, Request, RequestParserError, RequestParserResult, ResponseAttributes,
|
||||||
ResponseAttributes, ResponseParserError,
|
ResponseParserError, expect_property_type,
|
||||||
},
|
},
|
||||||
common::PlaylistName,
|
common::PlaylistName,
|
||||||
};
|
};
|
||||||
@ -37,17 +37,12 @@ impl Command for ListPlaylist {
|
|||||||
parts: ResponseAttributes<'_>,
|
parts: ResponseAttributes<'_>,
|
||||||
) -> Result<Self::Response, ResponseParserError> {
|
) -> Result<Self::Response, ResponseParserError> {
|
||||||
let parts: Vec<_> = parts.into();
|
let parts: Vec<_> = parts.into();
|
||||||
|
|
||||||
|
debug_assert!(parts.iter().all(|(k, _)| *k == "file"));
|
||||||
|
|
||||||
parts
|
parts
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(name, value)| {
|
.map(|(name, value)| Ok(expect_property_type!(Some(value), name, Text).to_string()))
|
||||||
debug_assert_eq!(name, "file");
|
|
||||||
match value {
|
|
||||||
GenericResponseValue::Text(value) => Ok(value.to_string()),
|
|
||||||
GenericResponseValue::Binary(_) => Err(
|
|
||||||
ResponseParserError::UnexpectedPropertyType("file", "Binary"),
|
|
||||||
),
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect::<Result<Vec<_>, _>>()
|
.collect::<Result<Vec<_>, _>>()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use crate::commands::{
|
use crate::commands::{
|
||||||
get_and_parse_property, Command, Request, RequestParserError, RequestParserResult,
|
Command, Request, RequestParserError, RequestParserResult, ResponseAttributes,
|
||||||
ResponseAttributes, ResponseParserError,
|
ResponseParserError, get_and_parse_property,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct PlaylistLength;
|
pub struct PlaylistLength;
|
||||||
|
@ -239,7 +239,7 @@ impl Request {
|
|||||||
.ok_or(RequestParserError::MissingCommandListEnd(i))?;
|
.ok_or(RequestParserError::MissingCommandListEnd(i))?;
|
||||||
match line.trim() {
|
match line.trim() {
|
||||||
"command_list_begin" => {
|
"command_list_begin" => {
|
||||||
return Err(RequestParserError::NestedCommandList(i))
|
return Err(RequestParserError::NestedCommandList(i));
|
||||||
}
|
}
|
||||||
"command_list_end" => {
|
"command_list_end" => {
|
||||||
return Ok((Request::CommandList(commands), rest));
|
return Ok((Request::CommandList(commands), rest));
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use crate::{common::SubSystem, Request, Response};
|
use crate::{Request, Response, common::SubSystem};
|
||||||
|
|
||||||
pub trait MPDServer {
|
pub trait MPDServer {
|
||||||
type Error;
|
type Error;
|
||||||
|
Reference in New Issue
Block a user