diff --git a/src/commands.rs b/src/commands.rs index c3a8aa4..37db815 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -139,18 +139,20 @@ impl<'a> From> for HashMap<&'a str, GenericResponseValue< macro_rules! get_property { ($parts:expr, $name:literal, $variant:ident) => { match $parts.get($name) { - Some(GenericResponseValue::$variant(value)) => *value, + Some(crate::commands::GenericResponseValue::$variant(value)) => *value, Some(value) => { let actual_type = match value { - GenericResponseValue::Text(_) => "Text", - GenericResponseValue::Binary(_) => "Binary", + crate::commands::GenericResponseValue::Text(_) => "Text", + crate::commands::GenericResponseValue::Binary(_) => "Binary", }; - return Err(ResponseParserError::UnexpectedPropertyType( - $name, - actual_type, - )); + return Err( + crate::commands::ResponseParserError::UnexpectedPropertyType( + $name, + actual_type, + ), + ); } - None => return Err(ResponseParserError::MissingProperty($name)), + None => return Err(crate::commands::ResponseParserError::MissingProperty($name)), } }; } @@ -158,16 +160,18 @@ macro_rules! get_property { macro_rules! get_optional_property { ($parts:expr, $name:literal, $variant:ident) => { match $parts.get($name) { - Some(GenericResponseValue::$variant(value)) => Some(*value), + Some(crate::commands::GenericResponseValue::$variant(value)) => Some(*value), Some(value) => { let actual_type = match value { - GenericResponseValue::Text(_) => "Text", - GenericResponseValue::Binary(_) => "Binary", + crate::commands::GenericResponseValue::Text(_) => "Text", + crate::commands::GenericResponseValue::Binary(_) => "Binary", }; - return Err(ResponseParserError::UnexpectedPropertyType( - $name, - actual_type, - )); + return Err( + crate::commands::ResponseParserError::UnexpectedPropertyType( + $name, + actual_type, + ), + ); } None => None, } @@ -177,20 +181,22 @@ macro_rules! get_optional_property { macro_rules! get_and_parse_property { ($parts:ident, $name:literal, $variant:ident) => { match $parts.get($name) { - Some(GenericResponseValue::$variant(value)) => (*value) + Some(crate::commands::GenericResponseValue::$variant(value)) => (*value) .parse() - .map_err(|_| ResponseParserError::InvalidProperty($name, value))?, + .map_err(|_| crate::commands::ResponseParserError::InvalidProperty($name, value))?, Some(value) => { let actual_type = match value { - GenericResponseValue::Text(_) => "Text", - GenericResponseValue::Binary(_) => "Binary", + crate::commands::GenericResponseValue::Text(_) => "Text", + crate::commands::GenericResponseValue::Binary(_) => "Binary", }; - return Err(ResponseParserError::UnexpectedPropertyType( - $name, - actual_type, - )); + return Err( + crate::commands::ResponseParserError::UnexpectedPropertyType( + $name, + actual_type, + ), + ); } - None => return Err(ResponseParserError::MissingProperty($name)), + None => return Err(crate::commands::ResponseParserError::MissingProperty($name)), } }; } @@ -198,20 +204,22 @@ macro_rules! get_and_parse_property { macro_rules! get_and_parse_optional_property { ($parts:ident, $name:literal, $variant:ident) => { match $parts.get($name) { - Some(GenericResponseValue::$variant(value)) => Some( - (*value) - .parse() - .map_err(|_| ResponseParserError::InvalidProperty($name, value))?, - ), + Some(crate::commands::GenericResponseValue::$variant(value)) => { + Some((*value).parse().map_err(|_| { + crate::commands::ResponseParserError::InvalidProperty($name, value) + })?) + } Some(value) => { let actual_type = match value { - GenericResponseValue::Text(_) => "Text", - GenericResponseValue::Binary(_) => "Binary", + crate::commands::GenericResponseValue::Text(_) => "Text", + crate::commands::GenericResponseValue::Binary(_) => "Binary", }; - return Err(ResponseParserError::UnexpectedPropertyType( - $name, - actual_type, - )); + return Err( + crate::commands::ResponseParserError::UnexpectedPropertyType( + $name, + actual_type, + ), + ); } None => None, } diff --git a/src/commands/playback_options/replay_gain_status.rs b/src/commands/playback_options/replay_gain_status.rs index 464766c..7342f25 100644 --- a/src/commands/playback_options/replay_gain_status.rs +++ b/src/commands/playback_options/replay_gain_status.rs @@ -2,8 +2,8 @@ use std::{collections::HashMap, str::FromStr}; use crate::{ commands::{ - get_property, Command, GenericResponseValue, Request, RequestParserResult, - ResponseAttributes, ResponseParserError, + get_property, Command, Request, RequestParserResult, ResponseAttributes, + ResponseParserError, }, request::ReplayGainModeMode, };