From 0a85bce52cd1fa71a10fc70c086b49a30cb95cc7 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Fri, 5 Dec 2025 22:00:11 +0900 Subject: [PATCH] commands: parse to `Self::Request` --- src/commands.rs | 8 +- .../audio_output_devices/disableoutput.rs | 6 +- .../audio_output_devices/enableoutput.rs | 6 +- src/commands/audio_output_devices/outputs.rs | 6 +- .../audio_output_devices/outputset.rs | 17 +- .../audio_output_devices/toggleoutput.rs | 6 +- src/commands/client_to_client/channels.rs | 6 +- src/commands/client_to_client/readmessages.rs | 6 +- src/commands/client_to_client/sendmessage.rs | 6 +- src/commands/client_to_client/subscribe.rs | 6 +- src/commands/client_to_client/unsubscribe.rs | 6 +- .../connection_settings/binary_limit.rs | 6 +- src/commands/connection_settings/close.rs | 6 +- src/commands/connection_settings/kill.rs | 6 +- src/commands/connection_settings/password.rs | 6 +- src/commands/connection_settings/ping.rs | 6 +- src/commands/connection_settings/protocol.rs | 7 +- .../connection_settings/protocol_all.rs | 7 +- .../connection_settings/protocol_available.rs | 7 +- .../connection_settings/protocol_clear.rs | 7 +- .../connection_settings/protocol_disable.rs | 7 +- .../connection_settings/protocol_enable.rs | 7 +- src/commands/connection_settings/tag_types.rs | 6 +- .../connection_settings/tag_types_all.rs | 7 +- .../tag_types_available.rs | 7 +- .../connection_settings/tag_types_clear.rs | 7 +- .../connection_settings/tag_types_disable.rs | 7 +- .../connection_settings/tag_types_enable.rs | 7 +- .../connection_settings/tag_types_reset.rs | 7 +- src/commands/controlling_playback/next.rs | 6 +- src/commands/controlling_playback/pause.rs | 10 +- src/commands/controlling_playback/play.rs | 6 +- src/commands/controlling_playback/playid.rs | 6 +- src/commands/controlling_playback/previous.rs | 6 +- src/commands/controlling_playback/seek.rs | 6 +- src/commands/controlling_playback/seekcur.rs | 9 +- src/commands/controlling_playback/seekid.rs | 6 +- src/commands/controlling_playback/stop.rs | 6 +- .../mounts_and_neighbors/listmounts.rs | 7 +- .../mounts_and_neighbors/listneighbors.rs | 7 +- src/commands/mounts_and_neighbors/mount.rs | 7 +- src/commands/mounts_and_neighbors/unmount.rs | 7 +- src/commands/music_database/albumart.rs | 9 +- src/commands/music_database/count.rs | 6 +- src/commands/music_database/find.rs | 10 +- src/commands/music_database/findadd.rs | 11 +- src/commands/music_database/getfingerprint.rs | 6 +- src/commands/music_database/list.rs | 11 +- src/commands/music_database/listall.rs | 6 +- src/commands/music_database/listallinfo.rs | 6 +- src/commands/music_database/listfiles.rs | 6 +- src/commands/music_database/lsinfo.rs | 6 +- src/commands/music_database/readcomments.rs | 6 +- src/commands/music_database/readpicture.rs | 9 +- src/commands/music_database/rescan.rs | 6 +- src/commands/music_database/search.rs | 10 +- src/commands/music_database/searchadd.rs | 14 +- src/commands/music_database/searchaddpl.rs | 18 +- src/commands/music_database/searchcount.rs | 6 +- src/commands/music_database/update.rs | 6 +- .../partition_commands/delpartition.rs | 6 +- .../partition_commands/listpartitions.rs | 6 +- src/commands/partition_commands/moveoutput.rs | 6 +- .../partition_commands/newpartition.rs | 6 +- src/commands/partition_commands/partition.rs | 6 +- src/commands/playback_options/consume.rs | 6 +- src/commands/playback_options/crossfade.rs | 6 +- src/commands/playback_options/getvol.rs | 6 +- src/commands/playback_options/mixrampdb.rs | 6 +- src/commands/playback_options/mixrampdelay.rs | 6 +- src/commands/playback_options/random.rs | 6 +- src/commands/playback_options/repeat.rs | 6 +- .../playback_options/replay_gain_mode.rs | 6 +- .../playback_options/replay_gain_status.rs | 6 +- src/commands/playback_options/setvol.rs | 6 +- src/commands/playback_options/single.rs | 6 +- src/commands/playback_options/volume.rs | 6 +- .../querying_mpd_status/clearerror.rs | 6 +- .../querying_mpd_status/currentsong.rs | 6 +- src/commands/querying_mpd_status/idle.rs | 20 +- src/commands/querying_mpd_status/stats.rs | 6 +- src/commands/querying_mpd_status/status.rs | 10 +- src/commands/queue/add.rs | 9 +- src/commands/queue/addid.rs | 9 +- src/commands/queue/addtagid.rs | 13 +- src/commands/queue/clear.rs | 6 +- src/commands/queue/cleartagid.rs | 7 +- src/commands/queue/delete.rs | 7 +- src/commands/queue/deleteid.rs | 7 +- src/commands/queue/move_.rs | 9 +- src/commands/queue/moveid.rs | 9 +- src/commands/queue/playlist.rs | 7 +- src/commands/queue/playlistfind.rs | 11 +- src/commands/queue/playlistid.rs | 7 +- src/commands/queue/playlistinfo.rs | 7 +- src/commands/queue/playlistsearch.rs | 11 +- src/commands/queue/plchanges.rs | 7 +- src/commands/queue/plchangesposid.rs | 7 +- src/commands/queue/prio.rs | 7 +- src/commands/queue/prioid.rs | 7 +- src/commands/queue/rangeid.rs | 10 +- src/commands/queue/shuffle.rs | 7 +- src/commands/queue/swap.rs | 7 +- src/commands/queue/swapid.rs | 7 +- src/commands/reflection/commands.rs | 6 +- src/commands/reflection/config.rs | 6 +- src/commands/reflection/decoders.rs | 6 +- src/commands/reflection/not_commands.rs | 6 +- src/commands/reflection/url_handlers.rs | 6 +- src/commands/stickers/sticker_dec.rs | 11 +- src/commands/stickers/sticker_delete.rs | 10 +- src/commands/stickers/sticker_find.rs | 15 +- src/commands/stickers/sticker_get.rs | 10 +- src/commands/stickers/sticker_inc.rs | 11 +- src/commands/stickers/sticker_list.rs | 6 +- src/commands/stickers/sticker_set.rs | 14 +- src/commands/stickers/stickernames.rs | 6 +- src/commands/stickers/stickernamestypes.rs | 14 +- src/commands/stickers/stickertypes.rs | 6 +- src/commands/stored_playlists/listplaylist.rs | 6 +- .../stored_playlists/listplaylistinfo.rs | 6 +- .../stored_playlists/listplaylists.rs | 6 +- src/commands/stored_playlists/load.rs | 10 +- src/commands/stored_playlists/playlistadd.rs | 10 +- .../stored_playlists/playlistclear.rs | 6 +- .../stored_playlists/playlistdelete.rs | 9 +- .../stored_playlists/playlistlength.rs | 6 +- src/commands/stored_playlists/playlistmove.rs | 10 +- src/commands/stored_playlists/rename.rs | 6 +- src/commands/stored_playlists/rm.rs | 6 +- src/commands/stored_playlists/save.rs | 9 +- .../stored_playlists/searchplaylist.rs | 10 +- src/lib.rs | 3 + src/request.rs | 366 +++++++++--------- 134 files changed, 710 insertions(+), 660 deletions(-) diff --git a/src/commands.rs b/src/commands.rs index 3b6408d..5889c0f 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -60,7 +60,7 @@ pub trait Command { /// ```ignore /// arg1 "arg2 arg3" /// ``` - fn parse_request(parts: RequestTokenizer<'_>) -> RequestParserResult<'_>; + fn parse_request(parts: RequestTokenizer<'_>) -> Result; /// Parse the raw request string into a request and the remaining unparsed string. /// This assumes the raw string starts with the command name, e.g. @@ -68,7 +68,7 @@ pub trait Command { /// ```ignore /// command_name arg1 "arg2 arg3" /// ``` - fn parse_raw_request(raw: &str) -> RequestParserResult<'_> { + fn parse_raw_request(raw: &str) -> Result<(Self::Request, &str), RequestParserError> { let (line, rest) = raw .split_once('\n') .ok_or(RequestParserError::UnexpectedEOF)?; @@ -81,7 +81,7 @@ pub trait Command { debug_assert!(command_name == Self::COMMAND); - Self::parse_request(tokenized).map(|(req, _)| (req, rest)) + Self::parse_request(tokenized).map(|req| (req, rest)) } /// Parse the response from its tokenized parts. @@ -94,7 +94,7 @@ pub trait Command { } } -pub type RequestParserResult<'a> = Result<(Request, &'a str), RequestParserError>; +// pub type RequestParserResult<'a> = ; #[derive(Debug, Clone, PartialEq)] pub enum RequestParserError { diff --git a/src/commands/audio_output_devices/disableoutput.rs b/src/commands/audio_output_devices/disableoutput.rs index 44d030c..54371b1 100644 --- a/src/commands/audio_output_devices/disableoutput.rs +++ b/src/commands/audio_output_devices/disableoutput.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::AudioOutputId, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -18,7 +18,7 @@ impl Command for DisableOutput { format!("{} {}", Self::COMMAND, request) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let output_id = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let output_id = output_id .parse() @@ -26,7 +26,7 @@ impl Command for DisableOutput { debug_assert!(parts.next().is_none()); - Ok((Request::DisableOutput(output_id), "")) + Ok(output_id) } fn parse_response( diff --git a/src/commands/audio_output_devices/enableoutput.rs b/src/commands/audio_output_devices/enableoutput.rs index 758ede1..424e43d 100644 --- a/src/commands/audio_output_devices/enableoutput.rs +++ b/src/commands/audio_output_devices/enableoutput.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::AudioOutputId, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -18,7 +18,7 @@ impl Command for EnableOutput { format!("{} {}", Self::COMMAND, request) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let output_id = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let output_id = output_id .parse() @@ -26,7 +26,7 @@ impl Command for EnableOutput { debug_assert!(parts.next().is_none()); - Ok((Request::EnableOutput(output_id), "")) + Ok(output_id) } fn parse_response( diff --git a/src/commands/audio_output_devices/outputs.rs b/src/commands/audio_output_devices/outputs.rs index 9b4e4ce..ca5f858 100644 --- a/src/commands/audio_output_devices/outputs.rs +++ b/src/commands/audio_output_devices/outputs.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::AudioOutputId, request_tokenizer::RequestTokenizer, response_tokenizer::{ResponseAttributes, expect_property_type}, @@ -31,9 +31,9 @@ impl Command for Outputs { Self::COMMAND.to_string() } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { debug_assert!(parts.next().is_none()); - Ok((Request::Outputs, "")) + Ok(()) } fn parse_response( diff --git a/src/commands/audio_output_devices/outputset.rs b/src/commands/audio_output_devices/outputset.rs index 2f78784..1b4f5d6 100644 --- a/src/commands/audio_output_devices/outputset.rs +++ b/src/commands/audio_output_devices/outputset.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::AudioOutputId, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -31,7 +31,7 @@ impl Command for OutputSet { ) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let output_id = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let output_id = output_id .parse() @@ -41,14 +41,11 @@ impl Command for OutputSet { debug_assert!(parts.next().is_none()); - Ok(( - Request::OutputSet( - output_id, - attribute_name.to_string(), - attribute_value.to_string(), - ), - "", - )) + Ok(OutputSetRequest { + output_id, + attribute_name: attribute_name.to_string(), + attribute_value: attribute_value.to_string(), + }) } fn parse_response( diff --git a/src/commands/audio_output_devices/toggleoutput.rs b/src/commands/audio_output_devices/toggleoutput.rs index 46434df..35d8bb0 100644 --- a/src/commands/audio_output_devices/toggleoutput.rs +++ b/src/commands/audio_output_devices/toggleoutput.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::AudioOutputId, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -18,7 +18,7 @@ impl Command for ToggleOutput { format!("{} {}", Self::COMMAND, request) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let output_id = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let output_id = output_id .parse() @@ -26,7 +26,7 @@ impl Command for ToggleOutput { debug_assert!(parts.next().is_none()); - Ok((Request::ToggleOutput(output_id), "")) + Ok(output_id) } fn parse_response( diff --git a/src/commands/client_to_client/channels.rs b/src/commands/client_to_client/channels.rs index 19aacdc..2c460e0 100644 --- a/src/commands/client_to_client/channels.rs +++ b/src/commands/client_to_client/channels.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::ChannelName, request_tokenizer::RequestTokenizer, response_tokenizer::{ResponseAttributes, expect_property_type}, @@ -23,10 +23,10 @@ impl Command for Channels { Self::COMMAND.to_string() } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { debug_assert!(parts.next().is_none()); - Ok((Request::Channels, "")) + Ok(()) } fn parse_response( diff --git a/src/commands/client_to_client/readmessages.rs b/src/commands/client_to_client/readmessages.rs index 60f0ea1..aa8652a 100644 --- a/src/commands/client_to_client/readmessages.rs +++ b/src/commands/client_to_client/readmessages.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::ChannelName, request_tokenizer::RequestTokenizer, response_tokenizer::{ResponseAttributes, expect_property_type}, @@ -26,10 +26,10 @@ impl Command for ReadMessages { Self::COMMAND.to_string() } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { debug_assert!(parts.next().is_none()); - Ok((Request::ReadMessages, "")) + Ok(()) } fn parse_response( diff --git a/src/commands/client_to_client/sendmessage.rs b/src/commands/client_to_client/sendmessage.rs index f209f1a..371123e 100644 --- a/src/commands/client_to_client/sendmessage.rs +++ b/src/commands/client_to_client/sendmessage.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::ChannelName, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -24,7 +24,7 @@ impl Command for SendMessage { format!("{} {} {}", Self::COMMAND, request.channel, request.message) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let channel = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let channel = channel .parse() @@ -35,7 +35,7 @@ impl Command for SendMessage { debug_assert!(!message.is_empty()); - Ok((Request::SendMessage(channel, message), "")) + Ok(SendMessageRequest { channel, message }) } fn parse_response( diff --git a/src/commands/client_to_client/subscribe.rs b/src/commands/client_to_client/subscribe.rs index 424b6a6..97c9281 100644 --- a/src/commands/client_to_client/subscribe.rs +++ b/src/commands/client_to_client/subscribe.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::ChannelName, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -16,7 +16,7 @@ impl Command for Subscribe { format!("{} {}", Self::COMMAND, request) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let channel_name = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let channel_name = channel_name .parse() @@ -24,7 +24,7 @@ impl Command for Subscribe { debug_assert!(parts.next().is_none()); - Ok((Request::Subscribe(channel_name), "")) + Ok(channel_name) } fn parse_response( diff --git a/src/commands/client_to_client/unsubscribe.rs b/src/commands/client_to_client/unsubscribe.rs index d5be5d9..05fe2ee 100644 --- a/src/commands/client_to_client/unsubscribe.rs +++ b/src/commands/client_to_client/unsubscribe.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::ChannelName, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -16,7 +16,7 @@ impl Command for Unsubscribe { format!("{} {}", Self::COMMAND, request) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let channel_name = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let channel_name = channel_name .parse() @@ -24,7 +24,7 @@ impl Command for Unsubscribe { debug_assert!(parts.next().is_none()); - Ok((Request::Unsubscribe(channel_name), "")) + Ok(channel_name) } fn parse_response( diff --git a/src/commands/connection_settings/binary_limit.rs b/src/commands/connection_settings/binary_limit.rs index 075094c..2e9b121 100644 --- a/src/commands/connection_settings/binary_limit.rs +++ b/src/commands/connection_settings/binary_limit.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, }; @@ -15,13 +15,13 @@ impl Command for BinaryLimit { format!("{} {}", Self::COMMAND, request) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let limit = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let limit = limit .parse() .map_err(|_| RequestParserError::SyntaxError(0, limit.to_string()))?; debug_assert!(parts.next().is_none()); - Ok((Request::BinaryLimit(limit), "")) + Ok(limit) } fn parse_response( diff --git a/src/commands/connection_settings/close.rs b/src/commands/connection_settings/close.rs index 640296f..6b8a061 100644 --- a/src/commands/connection_settings/close.rs +++ b/src/commands/connection_settings/close.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, }; @@ -15,9 +15,9 @@ impl Command for Close { Self::COMMAND.to_string() } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { debug_assert!(parts.next().is_none()); - Ok((Request::Close, "")) + Ok(()) } fn parse_response( diff --git a/src/commands/connection_settings/kill.rs b/src/commands/connection_settings/kill.rs index 534a55a..5a48014 100644 --- a/src/commands/connection_settings/kill.rs +++ b/src/commands/connection_settings/kill.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, }; @@ -15,9 +15,9 @@ impl Command for Kill { Self::COMMAND.to_string() } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { debug_assert!(parts.next().is_none()); - Ok((Request::Kill, "")) + Ok(()) } fn parse_response( diff --git a/src/commands/connection_settings/password.rs b/src/commands/connection_settings/password.rs index 919c442..9350fed 100644 --- a/src/commands/connection_settings/password.rs +++ b/src/commands/connection_settings/password.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, }; @@ -15,13 +15,13 @@ impl Command for Password { format!("{} {}", Self::COMMAND, request) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let password = parts .next() .ok_or(RequestParserError::UnexpectedEOF)? .to_string(); debug_assert!(parts.next().is_none()); - Ok((Request::Password(password), "")) + Ok(password) } fn parse_response( diff --git a/src/commands/connection_settings/ping.rs b/src/commands/connection_settings/ping.rs index 79074cd..dadb930 100644 --- a/src/commands/connection_settings/ping.rs +++ b/src/commands/connection_settings/ping.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, }; @@ -15,9 +15,9 @@ impl Command for Ping { Self::COMMAND.to_string() } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { debug_assert!(parts.next().is_none()); - Ok((Request::Ping, "")) + Ok(()) } fn parse_response( diff --git a/src/commands/connection_settings/protocol.rs b/src/commands/connection_settings/protocol.rs index 9acdce5..2ed3326 100644 --- a/src/commands/connection_settings/protocol.rs +++ b/src/commands/connection_settings/protocol.rs @@ -1,6 +1,5 @@ use crate::{ - Request, - commands::{Command, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, request_tokenizer::RequestTokenizer, response_tokenizer::{ResponseAttributes, expect_property_type}, }; @@ -18,9 +17,9 @@ impl Command for Protocol { Self::COMMAND.to_string() } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { debug_assert!(parts.next().is_none()); - Ok((Request::Protocol, "")) + Ok(()) } fn parse_response( diff --git a/src/commands/connection_settings/protocol_all.rs b/src/commands/connection_settings/protocol_all.rs index ea54689..4fb49ba 100644 --- a/src/commands/connection_settings/protocol_all.rs +++ b/src/commands/connection_settings/protocol_all.rs @@ -1,6 +1,5 @@ use crate::{ - Request, - commands::{Command, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, }; @@ -16,9 +15,9 @@ impl Command for ProtocolAll { Self::COMMAND.to_string() } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { debug_assert!(parts.next().is_none()); - Ok((Request::ProtocolAll, "")) + Ok(()) } fn parse_response( diff --git a/src/commands/connection_settings/protocol_available.rs b/src/commands/connection_settings/protocol_available.rs index c2b0416..528ee43 100644 --- a/src/commands/connection_settings/protocol_available.rs +++ b/src/commands/connection_settings/protocol_available.rs @@ -1,6 +1,5 @@ use crate::{ - Request, - commands::{Command, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, request_tokenizer::RequestTokenizer, response_tokenizer::{ResponseAttributes, expect_property_type}, }; @@ -18,9 +17,9 @@ impl Command for ProtocolAvailable { Self::COMMAND.to_string() } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { debug_assert!(parts.next().is_none()); - Ok((Request::ProtocolAvailable, "")) + Ok(()) } fn parse_response( diff --git a/src/commands/connection_settings/protocol_clear.rs b/src/commands/connection_settings/protocol_clear.rs index 9bb8077..21c3939 100644 --- a/src/commands/connection_settings/protocol_clear.rs +++ b/src/commands/connection_settings/protocol_clear.rs @@ -1,6 +1,5 @@ use crate::{ - Request, - commands::{Command, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, }; @@ -16,9 +15,9 @@ impl Command for ProtocolClear { Self::COMMAND.to_string() } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { debug_assert!(parts.next().is_none()); - Ok((Request::ProtocolClear, "")) + Ok(()) } fn parse_response( diff --git a/src/commands/connection_settings/protocol_disable.rs b/src/commands/connection_settings/protocol_disable.rs index adef348..727e7ba 100644 --- a/src/commands/connection_settings/protocol_disable.rs +++ b/src/commands/connection_settings/protocol_disable.rs @@ -1,6 +1,5 @@ use crate::{ - Request, - commands::{Command, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::Feature, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -19,7 +18,7 @@ impl Command for ProtocolDisable { format!("{} {}", Self::COMMAND, request.join(" ")) } - fn parse_request(parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(parts: RequestTokenizer<'_>) -> Result { let mut parts = parts.peekable(); if parts.peek().is_none() { return Err(RequestParserError::UnexpectedEOF); @@ -27,7 +26,7 @@ impl Command for ProtocolDisable { let features = parts.map(|s| s.to_string()).collect::>(); - Ok((Request::ProtocolDisable(features), "")) + Ok(features) } fn parse_response( diff --git a/src/commands/connection_settings/protocol_enable.rs b/src/commands/connection_settings/protocol_enable.rs index 9db44ed..bac14b9 100644 --- a/src/commands/connection_settings/protocol_enable.rs +++ b/src/commands/connection_settings/protocol_enable.rs @@ -1,6 +1,5 @@ use crate::{ - Request, - commands::{Command, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::Feature, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -19,7 +18,7 @@ impl Command for ProtocolEnable { format!("{} {}", Self::COMMAND, request.join(" ")) } - fn parse_request(parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(parts: RequestTokenizer<'_>) -> Result { let mut parts = parts.peekable(); if parts.peek().is_none() { return Err(RequestParserError::UnexpectedEOF); @@ -27,7 +26,7 @@ impl Command for ProtocolEnable { let features = parts.map(|s| s.to_string()).collect::>(); - Ok((Request::ProtocolEnable(features), "")) + Ok(features) } fn parse_response( diff --git a/src/commands/connection_settings/tag_types.rs b/src/commands/connection_settings/tag_types.rs index 6d52873..356cb54 100644 --- a/src/commands/connection_settings/tag_types.rs +++ b/src/commands/connection_settings/tag_types.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, request_tokenizer::RequestTokenizer, response_tokenizer::{ResponseAttributes, expect_property_type}, }; @@ -17,9 +17,9 @@ impl Command for TagTypes { Self::COMMAND.to_string() } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { debug_assert!(parts.next().is_none()); - Ok((Request::TagTypes, "")) + Ok(()) } fn parse_response( diff --git a/src/commands/connection_settings/tag_types_all.rs b/src/commands/connection_settings/tag_types_all.rs index 1e48a2f..de41601 100644 --- a/src/commands/connection_settings/tag_types_all.rs +++ b/src/commands/connection_settings/tag_types_all.rs @@ -1,6 +1,5 @@ use crate::{ - Request, - commands::{Command, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, }; @@ -16,9 +15,9 @@ impl Command for TagTypesAll { Self::COMMAND.to_string() } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { debug_assert!(parts.next().is_none()); - Ok((Request::TagTypesAll, "")) + Ok(()) } fn parse_response( diff --git a/src/commands/connection_settings/tag_types_available.rs b/src/commands/connection_settings/tag_types_available.rs index 17c2b87..609cf4e 100644 --- a/src/commands/connection_settings/tag_types_available.rs +++ b/src/commands/connection_settings/tag_types_available.rs @@ -1,6 +1,5 @@ use crate::{ - Request, - commands::{Command, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, request_tokenizer::RequestTokenizer, response_tokenizer::{ResponseAttributes, expect_property_type}, }; @@ -18,9 +17,9 @@ impl Command for TagTypesAvailable { Self::COMMAND.to_string() } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { debug_assert!(parts.next().is_none()); - Ok((Request::TagTypesAvailable, "")) + Ok(()) } fn parse_response( diff --git a/src/commands/connection_settings/tag_types_clear.rs b/src/commands/connection_settings/tag_types_clear.rs index 39f516d..2f68c7b 100644 --- a/src/commands/connection_settings/tag_types_clear.rs +++ b/src/commands/connection_settings/tag_types_clear.rs @@ -1,6 +1,5 @@ use crate::{ - Request, - commands::{Command, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, }; @@ -16,9 +15,9 @@ impl Command for TagTypesClear { Self::COMMAND.to_string() } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { debug_assert!(parts.next().is_none()); - Ok((Request::TagTypesClear, "")) + Ok(()) } fn parse_response( diff --git a/src/commands/connection_settings/tag_types_disable.rs b/src/commands/connection_settings/tag_types_disable.rs index 279f86c..5be6ba0 100644 --- a/src/commands/connection_settings/tag_types_disable.rs +++ b/src/commands/connection_settings/tag_types_disable.rs @@ -1,6 +1,5 @@ use crate::{ - Request, - commands::{Command, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::TagName, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -19,7 +18,7 @@ impl Command for TagTypesDisable { format!("{} {}", Self::COMMAND, request.join(" ")) } - fn parse_request(parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(parts: RequestTokenizer<'_>) -> Result { let mut parts = parts.peekable(); if parts.peek().is_none() { return Err(RequestParserError::UnexpectedEOF); @@ -27,7 +26,7 @@ impl Command for TagTypesDisable { let tag_types = parts.map(|s| s.to_string()).collect::>(); - Ok((Request::TagTypesDisable(tag_types), "")) + Ok(tag_types) } fn parse_response( diff --git a/src/commands/connection_settings/tag_types_enable.rs b/src/commands/connection_settings/tag_types_enable.rs index 59e352c..c408767 100644 --- a/src/commands/connection_settings/tag_types_enable.rs +++ b/src/commands/connection_settings/tag_types_enable.rs @@ -1,6 +1,5 @@ use crate::{ - Request, - commands::{Command, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::TagName, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -19,7 +18,7 @@ impl Command for TagTypesEnable { format!("{} {}", Self::COMMAND, request.join(" ")) } - fn parse_request(parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(parts: RequestTokenizer<'_>) -> Result { let mut parts = parts.peekable(); if parts.peek().is_none() { return Err(RequestParserError::UnexpectedEOF); @@ -27,7 +26,7 @@ impl Command for TagTypesEnable { let tag_types = parts.map(|s| s.to_string()).collect::>(); - Ok((Request::TagTypesEnable(tag_types), "")) + Ok(tag_types) } fn parse_response( diff --git a/src/commands/connection_settings/tag_types_reset.rs b/src/commands/connection_settings/tag_types_reset.rs index c6a5f23..ca8b29b 100644 --- a/src/commands/connection_settings/tag_types_reset.rs +++ b/src/commands/connection_settings/tag_types_reset.rs @@ -1,6 +1,5 @@ use crate::{ - Request, - commands::{Command, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::TagName, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -19,7 +18,7 @@ impl Command for TagTypesReset { format!("{} {}", Self::COMMAND, request.join(" ")) } - fn parse_request(parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(parts: RequestTokenizer<'_>) -> Result { let mut parts = parts.peekable(); if parts.peek().is_none() { return Err(RequestParserError::UnexpectedEOF); @@ -28,7 +27,7 @@ impl Command for TagTypesReset { // TODO: verify that the tag types are split by whitespace let tag_types = parts.map(|s| s.to_string()).collect::>(); - Ok((Request::TagTypesReset(tag_types), "")) + Ok(tag_types) } fn parse_response( diff --git a/src/commands/controlling_playback/next.rs b/src/commands/controlling_playback/next.rs index 451b6b1..16745ba 100644 --- a/src/commands/controlling_playback/next.rs +++ b/src/commands/controlling_playback/next.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, }; @@ -15,9 +15,9 @@ impl Command for Next { Self::COMMAND.to_string() } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { debug_assert!(parts.next().is_none()); - Ok((Request::Next, "")) + Ok(()) } fn parse_response( diff --git a/src/commands/controlling_playback/pause.rs b/src/commands/controlling_playback/pause.rs index 490579e..fbafcc3 100644 --- a/src/commands/controlling_playback/pause.rs +++ b/src/commands/controlling_playback/pause.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, }; @@ -19,12 +19,12 @@ impl Command for Pause { } } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let result = match parts.next() { - Some("0") => Ok((Request::Pause(Some(false)), "")), - Some("1") => Ok((Request::Pause(Some(true)), "")), + Some("0") => Ok(Some(false)), + Some("1") => Ok(Some(true)), Some(s) => Err(RequestParserError::SyntaxError(0, s.to_string())), - None => Ok((Request::Pause(None), "")), + None => Ok(None), }; debug_assert!(parts.next().is_none()); diff --git a/src/commands/controlling_playback/play.rs b/src/commands/controlling_playback/play.rs index 6990490..4504c44 100644 --- a/src/commands/controlling_playback/play.rs +++ b/src/commands/controlling_playback/play.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::SongPosition, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -16,7 +16,7 @@ impl Command for Play { format!("{} {}", Self::COMMAND, request) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let songpos = match parts.next() { Some(s) => s .parse::() @@ -26,7 +26,7 @@ impl Command for Play { debug_assert!(parts.next().is_none()); - Ok((Request::Play(songpos), "")) + Ok(songpos) } fn parse_response( diff --git a/src/commands/controlling_playback/playid.rs b/src/commands/controlling_playback/playid.rs index 859d3d5..6ab6f9d 100644 --- a/src/commands/controlling_playback/playid.rs +++ b/src/commands/controlling_playback/playid.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::SongId, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -16,7 +16,7 @@ impl Command for PlayId { format!("{} {}", Self::COMMAND, request) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let songid = match parts.next() { Some(s) => s .parse::() @@ -26,7 +26,7 @@ impl Command for PlayId { debug_assert!(parts.next().is_none()); - Ok((Request::PlayId(songid), "")) + Ok(songid) } fn parse_response( diff --git a/src/commands/controlling_playback/previous.rs b/src/commands/controlling_playback/previous.rs index f13a310..5a8f589 100644 --- a/src/commands/controlling_playback/previous.rs +++ b/src/commands/controlling_playback/previous.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, }; @@ -15,9 +15,9 @@ impl Command for Previous { Self::COMMAND.to_string() } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { debug_assert!(parts.next().is_none()); - Ok((Request::Previous, "")) + Ok(()) } fn parse_response( diff --git a/src/commands/controlling_playback/seek.rs b/src/commands/controlling_playback/seek.rs index ba5f0bc..2b15b33 100644 --- a/src/commands/controlling_playback/seek.rs +++ b/src/commands/controlling_playback/seek.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::{SongPosition, TimeWithFractions}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -24,7 +24,7 @@ impl Command for Seek { format!("{} {} {}", Self::COMMAND, request.songpos, request.time) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let songpos = match parts.next() { Some(s) => s .parse::() @@ -41,7 +41,7 @@ impl Command for Seek { debug_assert!(parts.next().is_none()); - Ok((Request::Seek(songpos, time), "")) + Ok(SeekRequest { songpos, time }) } fn parse_response( diff --git a/src/commands/controlling_playback/seekcur.rs b/src/commands/controlling_playback/seekcur.rs index e6ec0f9..0f20925 100644 --- a/src/commands/controlling_playback/seekcur.rs +++ b/src/commands/controlling_playback/seekcur.rs @@ -1,10 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - commands::{ - Command, Request, RequestParserError, RequestParserResult, ResponseAttributes, - ResponseParserError, - }, + commands::{Command, RequestParserError, ResponseAttributes, ResponseParserError}, common::types::{SeekMode, TimeWithFractions}, request_tokenizer::RequestTokenizer, }; @@ -33,7 +30,7 @@ impl Command for SeekCur { format!("{} {}", Self::COMMAND, time_str) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let time_raw = match parts.next() { Some(t) => t, None => return Err(RequestParserError::UnexpectedEOF), @@ -62,7 +59,7 @@ impl Command for SeekCur { debug_assert!(parts.next().is_none()); - Ok((Request::SeekCur(mode, time), "")) + Ok(SeekCurRequest { mode, time }) } fn parse_response( diff --git a/src/commands/controlling_playback/seekid.rs b/src/commands/controlling_playback/seekid.rs index 6f8c972..404243f 100644 --- a/src/commands/controlling_playback/seekid.rs +++ b/src/commands/controlling_playback/seekid.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::{SongId, TimeWithFractions}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -24,7 +24,7 @@ impl Command for SeekId { format!("{} {} {}", Self::COMMAND, request.songid, request.time) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let songid = match parts.next() { Some(s) => s .parse::() @@ -41,7 +41,7 @@ impl Command for SeekId { debug_assert!(parts.next().is_none()); - Ok((Request::SeekId(songid, time), "")) + Ok(SeekIdRequest { songid, time }) } fn parse_response( diff --git a/src/commands/controlling_playback/stop.rs b/src/commands/controlling_playback/stop.rs index ec65d00..a55075c 100644 --- a/src/commands/controlling_playback/stop.rs +++ b/src/commands/controlling_playback/stop.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, }; @@ -15,9 +15,9 @@ impl Command for Stop { Self::COMMAND.to_string() } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { debug_assert!(parts.next().is_none()); - Ok((Request::Stop, "")) + Ok(()) } fn parse_response( diff --git a/src/commands/mounts_and_neighbors/listmounts.rs b/src/commands/mounts_and_neighbors/listmounts.rs index 1cb992c..5c10ab0 100644 --- a/src/commands/mounts_and_neighbors/listmounts.rs +++ b/src/commands/mounts_and_neighbors/listmounts.rs @@ -1,6 +1,5 @@ use crate::{ - Request, - commands::{Command, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, request_tokenizer::RequestTokenizer, response_tokenizer::{ResponseAttributes, expect_property_type}, }; @@ -16,9 +15,9 @@ impl Command for ListMounts { Self::COMMAND.to_string() } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { debug_assert!(parts.next().is_none()); - Ok((Request::ListMounts, "")) + Ok(()) } fn parse_response( diff --git a/src/commands/mounts_and_neighbors/listneighbors.rs b/src/commands/mounts_and_neighbors/listneighbors.rs index 78c763c..8285843 100644 --- a/src/commands/mounts_and_neighbors/listneighbors.rs +++ b/src/commands/mounts_and_neighbors/listneighbors.rs @@ -1,8 +1,7 @@ use std::collections::HashMap; use crate::{ - Request, - commands::{Command, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, request_tokenizer::RequestTokenizer, response_tokenizer::{ResponseAttributes, expect_property_type}, }; @@ -20,9 +19,9 @@ impl Command for ListNeighbors { Self::COMMAND.to_string() } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { debug_assert!(parts.next().is_none()); - Ok((Request::ListNeighbors, "")) + Ok(()) } fn parse_response( diff --git a/src/commands/mounts_and_neighbors/mount.rs b/src/commands/mounts_and_neighbors/mount.rs index 9df1f21..ff920e4 100644 --- a/src/commands/mounts_and_neighbors/mount.rs +++ b/src/commands/mounts_and_neighbors/mount.rs @@ -1,8 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - Request, - commands::{Command, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, }; @@ -24,7 +23,7 @@ impl Command for Mount { format!("{} {} {}", Self::COMMAND, request.path, request.uri) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let path = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let path = path .parse() @@ -37,7 +36,7 @@ impl Command for Mount { debug_assert!(parts.next().is_none()); - Ok((Request::Mount(path, uri), "")) + Ok(MountRequest { path, uri }) } fn parse_response( diff --git a/src/commands/mounts_and_neighbors/unmount.rs b/src/commands/mounts_and_neighbors/unmount.rs index 5adaf44..fe85e2d 100644 --- a/src/commands/mounts_and_neighbors/unmount.rs +++ b/src/commands/mounts_and_neighbors/unmount.rs @@ -1,6 +1,5 @@ use crate::{ - Request, - commands::{Command, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, }; @@ -18,7 +17,7 @@ impl Command for Unmount { format!("{} {}", Self::COMMAND, request) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let path = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let path = path .parse() @@ -26,7 +25,7 @@ impl Command for Unmount { debug_assert!(parts.next().is_none()); - Ok((Request::Unmount(path), "")) + Ok(path) } fn parse_response( diff --git a/src/commands/music_database/albumart.rs b/src/commands/music_database/albumart.rs index 859d7b2..df995dd 100644 --- a/src/commands/music_database/albumart.rs +++ b/src/commands/music_database/albumart.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::{Offset, Uri}, request_tokenizer::RequestTokenizer, response_tokenizer::{ResponseAttributes, get_and_parse_property, get_property}, @@ -32,7 +32,7 @@ impl Command for AlbumArt { format!("{} {} {}", Self::COMMAND, request.uri, request.offset) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let uri = match parts.next() { Some(s) => s, None => return Err(RequestParserError::UnexpectedEOF), @@ -47,7 +47,10 @@ impl Command for AlbumArt { debug_assert!(parts.next().is_none()); - Ok((Request::AlbumArt(uri.to_string(), offset), "")) + Ok(AlbumArtRequest { + uri: uri.to_string(), + offset, + }) } fn parse_response( diff --git a/src/commands/music_database/count.rs b/src/commands/music_database/count.rs index c7a55d8..07e1283 100644 --- a/src/commands/music_database/count.rs +++ b/src/commands/music_database/count.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::GroupType, filter::Filter, request_tokenizer::RequestTokenizer, @@ -37,7 +37,7 @@ impl Command for Count { cmd } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let filter = match parts.next() { Some(f) => { Filter::parse(f).map_err(|_| RequestParserError::SyntaxError(1, f.to_owned()))? @@ -59,7 +59,7 @@ impl Command for Count { debug_assert!(parts.next().is_none()); - Ok((Request::Count(filter, group), "")) + Ok(CountRequest { filter, group }) } fn parse_response( diff --git a/src/commands/music_database/find.rs b/src/commands/music_database/find.rs index 180ea7f..3fec6d7 100644 --- a/src/commands/music_database/find.rs +++ b/src/commands/music_database/find.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::{Sort, WindowRange}, filter::Filter, request_tokenizer::RequestTokenizer, @@ -36,7 +36,7 @@ impl Command for Find { cmd } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let filter = match parts.next() { Some(f) => { Filter::parse(f).map_err(|_| RequestParserError::SyntaxError(1, f.to_owned()))? @@ -66,7 +66,11 @@ impl Command for Find { debug_assert!(parts.next().is_none()); - Ok((Request::Find(filter, sort, window), "")) + Ok(FindRequest { + filter, + sort, + window, + }) } fn parse_response( diff --git a/src/commands/music_database/findadd.rs b/src/commands/music_database/findadd.rs index 9087b69..75ce433 100644 --- a/src/commands/music_database/findadd.rs +++ b/src/commands/music_database/findadd.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::{SongPosition, Sort, WindowRange}, filter::Filter, request_tokenizer::RequestTokenizer, @@ -37,7 +37,7 @@ impl Command for FindAdd { cmd } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let filter = match parts.next() { Some(f) => { Filter::parse(f).map_err(|_| RequestParserError::SyntaxError(1, f.to_owned()))? @@ -77,7 +77,12 @@ impl Command for FindAdd { debug_assert!(parts.next().is_none()); - Ok((Request::FindAdd(filter, sort, window, position), "")) + Ok(FindAddRequest { + filter, + sort, + window, + position, + }) } fn parse_response( diff --git a/src/commands/music_database/getfingerprint.rs b/src/commands/music_database/getfingerprint.rs index 37738b3..bff8b58 100644 --- a/src/commands/music_database/getfingerprint.rs +++ b/src/commands/music_database/getfingerprint.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::Uri, request_tokenizer::RequestTokenizer, response_tokenizer::{ResponseAttributes, get_and_parse_property}, @@ -25,7 +25,7 @@ impl Command for GetFingerprint { format!("{} {}", Self::COMMAND, request) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let uri = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let uri = uri .parse() @@ -33,7 +33,7 @@ impl Command for GetFingerprint { debug_assert!(parts.next().is_none()); - Ok((Request::GetFingerprint(uri), "")) + Ok(uri) } fn parse_response( diff --git a/src/commands/music_database/list.rs b/src/commands/music_database/list.rs index 204b31b..96ae689 100644 --- a/src/commands/music_database/list.rs +++ b/src/commands/music_database/list.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::{GroupType, TagName, WindowRange}, filter::Filter, request_tokenizer::RequestTokenizer, @@ -39,7 +39,7 @@ impl Command for List { cmd } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let tagname = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let tagname = tagname .parse() @@ -84,7 +84,12 @@ impl Command for List { debug_assert!(parts.next().is_none()); - Ok((Request::List(tagname, filter, groups, window), "")) + Ok(ListRequest { + tagname, + filter, + groups, + window, + }) } fn parse_response( diff --git a/src/commands/music_database/listall.rs b/src/commands/music_database/listall.rs index 8c35b9e..be708b6 100644 --- a/src/commands/music_database/listall.rs +++ b/src/commands/music_database/listall.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::Uri, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -23,7 +23,7 @@ impl Command for ListAll { } } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let uri = parts .next() .map(|s| { @@ -34,7 +34,7 @@ impl Command for ListAll { debug_assert!(parts.next().is_none()); - Ok((Request::ListAll(uri), "")) + Ok(uri) } fn parse_response( diff --git a/src/commands/music_database/listallinfo.rs b/src/commands/music_database/listallinfo.rs index 623fb4f..1fa0de7 100644 --- a/src/commands/music_database/listallinfo.rs +++ b/src/commands/music_database/listallinfo.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::Uri, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -24,7 +24,7 @@ impl Command for ListAllInfo { } } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let uri = parts .next() .map(|s| { @@ -35,7 +35,7 @@ impl Command for ListAllInfo { debug_assert!(parts.next().is_none()); - Ok((Request::ListAllInfo(uri), "")) + Ok(uri) } fn parse_response( diff --git a/src/commands/music_database/listfiles.rs b/src/commands/music_database/listfiles.rs index 2dfd922..a984b32 100644 --- a/src/commands/music_database/listfiles.rs +++ b/src/commands/music_database/listfiles.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::Uri, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -23,7 +23,7 @@ impl Command for ListFiles { } } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let uri = parts .next() .map(|s| { @@ -34,7 +34,7 @@ impl Command for ListFiles { debug_assert!(parts.next().is_none()); - Ok((Request::ListFiles(uri), "")) + Ok(uri) } fn parse_response( diff --git a/src/commands/music_database/lsinfo.rs b/src/commands/music_database/lsinfo.rs index 495543a..de9898a 100644 --- a/src/commands/music_database/lsinfo.rs +++ b/src/commands/music_database/lsinfo.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::Uri, request_tokenizer::RequestTokenizer, response_tokenizer::{ResponseAttributes, expect_property_type}, @@ -29,7 +29,7 @@ impl Command for LsInfo { } } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let uri = parts .next() .map(|s| { @@ -40,7 +40,7 @@ impl Command for LsInfo { debug_assert!(parts.next().is_none()); - Ok((Request::LsInfo(uri), "")) + Ok(uri) } fn parse_response( diff --git a/src/commands/music_database/readcomments.rs b/src/commands/music_database/readcomments.rs index 17764ef..32069e8 100644 --- a/src/commands/music_database/readcomments.rs +++ b/src/commands/music_database/readcomments.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::Uri, request_tokenizer::RequestTokenizer, response_tokenizer::{GenericResponseValue, ResponseAttributes}, @@ -20,7 +20,7 @@ impl Command for ReadComments { format!("{} {}", Self::COMMAND, request) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let uri = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let uri = uri .parse() @@ -28,7 +28,7 @@ impl Command for ReadComments { debug_assert!(parts.next().is_none()); - Ok((Request::ReadComments(uri), "")) + Ok(uri) } fn parse_response( diff --git a/src/commands/music_database/readpicture.rs b/src/commands/music_database/readpicture.rs index a269c97..dfbdd96 100644 --- a/src/commands/music_database/readpicture.rs +++ b/src/commands/music_database/readpicture.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::{Offset, Uri}, request_tokenizer::RequestTokenizer, response_tokenizer::{ @@ -35,7 +35,7 @@ impl Command for ReadPicture { format!("{} {} {}", Self::COMMAND, request.uri, request.offset) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let uri = match parts.next() { Some(s) => s, None => return Err(RequestParserError::UnexpectedEOF), @@ -50,7 +50,10 @@ impl Command for ReadPicture { debug_assert!(parts.next().is_none()); - Ok((Request::ReadPicture(uri.to_string(), offset), "")) + Ok(ReadPictureRequest { + uri: uri.to_string(), + offset, + }) } fn parse_response( diff --git a/src/commands/music_database/rescan.rs b/src/commands/music_database/rescan.rs index eb5be15..170552c 100644 --- a/src/commands/music_database/rescan.rs +++ b/src/commands/music_database/rescan.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::Uri, request_tokenizer::RequestTokenizer, response_tokenizer::{ResponseAttributes, get_and_parse_property}, @@ -28,12 +28,12 @@ impl Command for Rescan { } } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let uri = parts.next().map(|s| s.to_string()); debug_assert!(parts.next().is_none()); - Ok((Request::Rescan(uri), "")) + Ok(uri) } fn parse_response( diff --git a/src/commands/music_database/search.rs b/src/commands/music_database/search.rs index de3601d..7f4596c 100644 --- a/src/commands/music_database/search.rs +++ b/src/commands/music_database/search.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::{Sort, WindowRange}, filter::Filter, request_tokenizer::RequestTokenizer, @@ -36,7 +36,7 @@ impl Command for Search { cmd } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let filter = match parts.next() { Some(f) => { Filter::parse(f).map_err(|_| RequestParserError::SyntaxError(1, f.to_owned()))? @@ -66,7 +66,11 @@ impl Command for Search { debug_assert!(parts.next().is_none()); - Ok((Request::Search(filter, sort, window), "")) + Ok(SearchRequest { + filter, + sort, + window, + }) } fn parse_response( diff --git a/src/commands/music_database/searchadd.rs b/src/commands/music_database/searchadd.rs index c84e14c..580a653 100644 --- a/src/commands/music_database/searchadd.rs +++ b/src/commands/music_database/searchadd.rs @@ -1,10 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - commands::{ - Command, Request, RequestParserError, RequestParserResult, ResponseAttributes, - ResponseParserError, - }, + commands::{Command, RequestParserError, ResponseAttributes, ResponseParserError}, common::types::{SongPosition, Sort, WindowRange}, filter::Filter, request_tokenizer::RequestTokenizer, @@ -39,7 +36,7 @@ impl Command for SearchAdd { cmd } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let filter = match parts.next() { Some(f) => { Filter::parse(f).map_err(|_| RequestParserError::SyntaxError(1, f.to_owned()))? @@ -79,7 +76,12 @@ impl Command for SearchAdd { debug_assert!(parts.next().is_none()); - Ok((Request::SearchAdd(filter, sort, window, position), "")) + Ok(SearchAddRequest { + filter, + sort, + window, + position, + }) } fn parse_response( diff --git a/src/commands/music_database/searchaddpl.rs b/src/commands/music_database/searchaddpl.rs index bdb2be0..a6edd29 100644 --- a/src/commands/music_database/searchaddpl.rs +++ b/src/commands/music_database/searchaddpl.rs @@ -1,10 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - commands::{ - Command, Request, RequestParserError, RequestParserResult, ResponseAttributes, - ResponseParserError, - }, + commands::{Command, RequestParserError, ResponseAttributes, ResponseParserError}, common::types::{PlaylistName, SongPosition, Sort, WindowRange}, filter::Filter, request_tokenizer::RequestTokenizer, @@ -45,7 +42,7 @@ impl Command for SearchAddPl { cmd } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let playlist_name = parts .next() .ok_or(RequestParserError::UnexpectedEOF)? @@ -90,10 +87,13 @@ impl Command for SearchAddPl { debug_assert!(parts.next().is_none()); - Ok(( - Request::SearchAddPl(playlist_name, filter, sort, window, position), - "", - )) + Ok(SearchAddPlRequest { + playlist_name, + filter, + sort, + window, + position, + }) } fn parse_response( diff --git a/src/commands/music_database/searchcount.rs b/src/commands/music_database/searchcount.rs index ab986e8..0261216 100644 --- a/src/commands/music_database/searchcount.rs +++ b/src/commands/music_database/searchcount.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::GroupType, filter::Filter, request_tokenizer::RequestTokenizer, @@ -37,7 +37,7 @@ impl Command for SearchCount { cmd } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let filter = match parts.next() { Some(f) => { Filter::parse(f).map_err(|_| RequestParserError::SyntaxError(1, f.to_owned()))? @@ -58,7 +58,7 @@ impl Command for SearchCount { debug_assert!(parts.next().is_none()); - Ok((Request::SearchCount(filter, group), "")) + Ok(SearchCountRequest { filter, group }) } fn parse_response( diff --git a/src/commands/music_database/update.rs b/src/commands/music_database/update.rs index f37ef56..ecd9312 100644 --- a/src/commands/music_database/update.rs +++ b/src/commands/music_database/update.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::Uri, request_tokenizer::RequestTokenizer, response_tokenizer::{ResponseAttributes, get_and_parse_property}, @@ -28,12 +28,12 @@ impl Command for Update { } } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let uri = parts.next().map(|s| s.to_string()); debug_assert!(parts.next().is_none()); - Ok((Request::Update(uri), "")) + Ok(uri) } fn parse_response( diff --git a/src/commands/partition_commands/delpartition.rs b/src/commands/partition_commands/delpartition.rs index 4fe6cc7..f39d160 100644 --- a/src/commands/partition_commands/delpartition.rs +++ b/src/commands/partition_commands/delpartition.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::PartitionName, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -16,7 +16,7 @@ impl Command for DelPartition { format!("{} {}", Self::COMMAND, request) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let partition = parts .next() .ok_or(RequestParserError::UnexpectedEOF)? @@ -24,7 +24,7 @@ impl Command for DelPartition { debug_assert!(parts.next().is_none()); - Ok((Request::DelPartition(partition), "")) + Ok(partition) } fn parse_response( diff --git a/src/commands/partition_commands/listpartitions.rs b/src/commands/partition_commands/listpartitions.rs index 6da2010..2796f7e 100644 --- a/src/commands/partition_commands/listpartitions.rs +++ b/src/commands/partition_commands/listpartitions.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::PartitionName, request_tokenizer::RequestTokenizer, response_tokenizer::{ResponseAttributes, expect_property_type}, @@ -18,9 +18,9 @@ impl Command for ListPartitions { Self::COMMAND.to_string() } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { debug_assert!(parts.next().is_none()); - Ok((Request::ListPartitions, "")) + Ok(()) } fn parse_response( diff --git a/src/commands/partition_commands/moveoutput.rs b/src/commands/partition_commands/moveoutput.rs index db5f65e..6eb4a8e 100644 --- a/src/commands/partition_commands/moveoutput.rs +++ b/src/commands/partition_commands/moveoutput.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, }; @@ -15,7 +15,7 @@ impl Command for MoveOutput { format!("{} {}", Self::COMMAND, request) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let output_name = parts .next() .ok_or(RequestParserError::UnexpectedEOF)? @@ -23,7 +23,7 @@ impl Command for MoveOutput { debug_assert!(parts.next().is_none()); - Ok((Request::MoveOutput(output_name), "")) + Ok(output_name) } fn parse_response( diff --git a/src/commands/partition_commands/newpartition.rs b/src/commands/partition_commands/newpartition.rs index 23bc6a9..42dff24 100644 --- a/src/commands/partition_commands/newpartition.rs +++ b/src/commands/partition_commands/newpartition.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::PartitionName, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -16,7 +16,7 @@ impl Command for NewPartition { format!("{} {}", Self::COMMAND, request) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let partition = parts .next() .ok_or(RequestParserError::UnexpectedEOF)? @@ -24,7 +24,7 @@ impl Command for NewPartition { debug_assert!(parts.next().is_none()); - Ok((Request::NewPartition(partition), "")) + Ok(partition) } fn parse_response( diff --git a/src/commands/partition_commands/partition.rs b/src/commands/partition_commands/partition.rs index f64d12b..89bd1eb 100644 --- a/src/commands/partition_commands/partition.rs +++ b/src/commands/partition_commands/partition.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::PartitionName, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -16,7 +16,7 @@ impl Command for Partition { format!("{} {}", Self::COMMAND, request) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let partition = parts .next() .ok_or(RequestParserError::UnexpectedEOF)? @@ -24,7 +24,7 @@ impl Command for Partition { debug_assert!(parts.next().is_none()); - Ok((Request::Partition(partition), "")) + Ok(partition) } fn parse_response( diff --git a/src/commands/playback_options/consume.rs b/src/commands/playback_options/consume.rs index 7629163..58222c7 100644 --- a/src/commands/playback_options/consume.rs +++ b/src/commands/playback_options/consume.rs @@ -1,7 +1,7 @@ use std::str::FromStr; use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::BoolOrOneshot, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -18,7 +18,7 @@ impl Command for Consume { format!("{} {}", Self::COMMAND, request) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let state = match parts.next() { Some(s) => crate::common::types::BoolOrOneshot::from_str(s) .map_err(|_| RequestParserError::SyntaxError(0, s.to_owned()))?, @@ -27,7 +27,7 @@ impl Command for Consume { debug_assert!(parts.next().is_none()); - Ok((Request::Consume(state), "")) + Ok(state) } fn parse_response( diff --git a/src/commands/playback_options/crossfade.rs b/src/commands/playback_options/crossfade.rs index ba7f286..48558e1 100644 --- a/src/commands/playback_options/crossfade.rs +++ b/src/commands/playback_options/crossfade.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::Seconds, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -16,7 +16,7 @@ impl Command for Crossfade { format!("{} {}", Self::COMMAND, request) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let seconds = match parts.next() { Some(s) => s .parse::() @@ -26,7 +26,7 @@ impl Command for Crossfade { debug_assert!(parts.next().is_none()); - Ok((Request::Crossfade(seconds), "")) + Ok(seconds) } fn parse_response( diff --git a/src/commands/playback_options/getvol.rs b/src/commands/playback_options/getvol.rs index 7966893..a81fa57 100644 --- a/src/commands/playback_options/getvol.rs +++ b/src/commands/playback_options/getvol.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use crate::{ - commands::{Command, Request, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::VolumeValue, request_tokenizer::RequestTokenizer, response_tokenizer::{ResponseAttributes, get_and_parse_property}, @@ -18,9 +18,9 @@ impl Command for GetVol { Self::COMMAND.to_string() } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { debug_assert!(parts.next().is_none()); - Ok((Request::GetVol, "")) + Ok(()) } fn parse_response( diff --git a/src/commands/playback_options/mixrampdb.rs b/src/commands/playback_options/mixrampdb.rs index 354d7fe..c2306d0 100644 --- a/src/commands/playback_options/mixrampdb.rs +++ b/src/commands/playback_options/mixrampdb.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, }; @@ -15,7 +15,7 @@ impl Command for MixRampDb { format!("{} {}", Self::COMMAND, request) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let db = match parts.next() { Some(s) => s .parse::() @@ -25,7 +25,7 @@ impl Command for MixRampDb { debug_assert!(parts.next().is_none()); - Ok((Request::MixRampDb(db), "")) + Ok(db) } fn parse_response( diff --git a/src/commands/playback_options/mixrampdelay.rs b/src/commands/playback_options/mixrampdelay.rs index f74c7e3..348820c 100644 --- a/src/commands/playback_options/mixrampdelay.rs +++ b/src/commands/playback_options/mixrampdelay.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::Seconds, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -16,7 +16,7 @@ impl Command for MixRampDelay { format!("{} {}", Self::COMMAND, request) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let seconds = match parts.next() { Some(s) => s .parse::() @@ -26,7 +26,7 @@ impl Command for MixRampDelay { debug_assert!(parts.next().is_none()); - Ok((Request::MixRampDelay(seconds), "")) + Ok(seconds) } fn parse_response( diff --git a/src/commands/playback_options/random.rs b/src/commands/playback_options/random.rs index 2e39867..4f2fb79 100644 --- a/src/commands/playback_options/random.rs +++ b/src/commands/playback_options/random.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, }; @@ -16,7 +16,7 @@ impl Command for Random { format!("{} {}", Self::COMMAND, state) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let state = match parts.next() { Some("0") => false, Some("1") => true, @@ -26,7 +26,7 @@ impl Command for Random { debug_assert!(parts.next().is_none()); - Ok((Request::Random(state), "")) + Ok(state) } fn parse_response( diff --git a/src/commands/playback_options/repeat.rs b/src/commands/playback_options/repeat.rs index 641b5e7..d7e73d2 100644 --- a/src/commands/playback_options/repeat.rs +++ b/src/commands/playback_options/repeat.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, }; @@ -16,7 +16,7 @@ impl Command for Repeat { format!("{} {}", Self::COMMAND, state) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let state = match parts.next() { Some("0") => false, Some("1") => true, @@ -26,7 +26,7 @@ impl Command for Repeat { debug_assert!(parts.next().is_none()); - Ok((Request::Repeat(state), "")) + Ok(state) } fn parse_response( diff --git a/src/commands/playback_options/replay_gain_mode.rs b/src/commands/playback_options/replay_gain_mode.rs index a50fb34..5de1da1 100644 --- a/src/commands/playback_options/replay_gain_mode.rs +++ b/src/commands/playback_options/replay_gain_mode.rs @@ -1,7 +1,7 @@ use std::str::FromStr; use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::ReplayGainModeMode, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -18,7 +18,7 @@ impl Command for ReplayGainMode { format!("{} {}", Self::COMMAND, request) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let mode = match parts.next() { Some(s) => ReplayGainModeMode::from_str(s) .map_err(|_| RequestParserError::SyntaxError(0, s.to_owned()))?, @@ -27,7 +27,7 @@ impl Command for ReplayGainMode { debug_assert!(parts.next().is_none()); - Ok((Request::ReplayGainMode(mode), "")) + Ok(mode) } fn parse_response( diff --git a/src/commands/playback_options/replay_gain_status.rs b/src/commands/playback_options/replay_gain_status.rs index cfa34b7..4402ec4 100644 --- a/src/commands/playback_options/replay_gain_status.rs +++ b/src/commands/playback_options/replay_gain_status.rs @@ -3,7 +3,7 @@ use std::{collections::HashMap, str::FromStr}; use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::ReplayGainModeMode, request_tokenizer::RequestTokenizer, response_tokenizer::{ResponseAttributes, get_property}, @@ -25,9 +25,9 @@ impl Command for ReplayGainStatus { Self::COMMAND.to_string() } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { debug_assert!(parts.next().is_none()); - Ok((Request::ReplayGainStatus, "")) + Ok(()) } fn parse_response( diff --git a/src/commands/playback_options/setvol.rs b/src/commands/playback_options/setvol.rs index c956f95..071dfd3 100644 --- a/src/commands/playback_options/setvol.rs +++ b/src/commands/playback_options/setvol.rs @@ -1,7 +1,7 @@ use std::str::FromStr; use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::VolumeValue, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -18,7 +18,7 @@ impl Command for SetVol { format!("{} {}", Self::COMMAND, request) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let volume = match parts.next() { Some(s) => VolumeValue::from_str(s) .map_err(|_| RequestParserError::SyntaxError(0, s.to_owned()))?, @@ -27,7 +27,7 @@ impl Command for SetVol { debug_assert!(parts.next().is_none()); - Ok((Request::SetVol(volume), "")) + Ok(volume) } fn parse_response( diff --git a/src/commands/playback_options/single.rs b/src/commands/playback_options/single.rs index b26305e..3614dd6 100644 --- a/src/commands/playback_options/single.rs +++ b/src/commands/playback_options/single.rs @@ -1,7 +1,7 @@ use std::str::FromStr; use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::BoolOrOneshot, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -18,7 +18,7 @@ impl Command for Single { format!("{} {}", Self::COMMAND, request) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let state = match parts.next() { Some(s) => crate::common::types::BoolOrOneshot::from_str(s) .map_err(|_| RequestParserError::SyntaxError(0, s.to_owned()))?, @@ -27,7 +27,7 @@ impl Command for Single { debug_assert!(parts.next().is_none()); - Ok((Request::Single(state), "")) + Ok(state) } fn parse_response( diff --git a/src/commands/playback_options/volume.rs b/src/commands/playback_options/volume.rs index ce37f72..5d8f7c8 100644 --- a/src/commands/playback_options/volume.rs +++ b/src/commands/playback_options/volume.rs @@ -1,7 +1,7 @@ use std::str::FromStr; use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::VolumeValue, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -18,7 +18,7 @@ impl Command for Volume { format!("{} {}", Self::COMMAND, request) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let change = match parts.next() { Some(s) => VolumeValue::from_str(s) .map_err(|_| RequestParserError::SyntaxError(0, s.to_owned()))?, @@ -27,7 +27,7 @@ impl Command for Volume { debug_assert!(parts.next().is_none()); - Ok((Request::Volume(change), "")) + Ok(change) } fn parse_response( diff --git a/src/commands/querying_mpd_status/clearerror.rs b/src/commands/querying_mpd_status/clearerror.rs index c7e4909..324a43c 100644 --- a/src/commands/querying_mpd_status/clearerror.rs +++ b/src/commands/querying_mpd_status/clearerror.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, }; @@ -16,10 +16,10 @@ impl Command for ClearError { Self::COMMAND.to_string() } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { debug_assert!(parts.next().is_none()); - Ok((Request::ClearError, "")) + Ok(()) } fn parse_response( diff --git a/src/commands/querying_mpd_status/currentsong.rs b/src/commands/querying_mpd_status/currentsong.rs index e9ec3e3..d8be0a3 100644 --- a/src/commands/querying_mpd_status/currentsong.rs +++ b/src/commands/querying_mpd_status/currentsong.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, }; @@ -21,10 +21,10 @@ impl Command for CurrentSong { Self::COMMAND.to_string() } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { debug_assert!(parts.next().is_none()); - Ok((Request::CurrentSong, "")) + Ok(()) } fn parse_response( diff --git a/src/commands/querying_mpd_status/idle.rs b/src/commands/querying_mpd_status/idle.rs index dede02b..dcd841b 100644 --- a/src/commands/querying_mpd_status/idle.rs +++ b/src/commands/querying_mpd_status/idle.rs @@ -1,7 +1,7 @@ use std::str::FromStr; use crate::{ - commands::{Command, Request, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::SubSystem, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -30,16 +30,14 @@ impl Command for Idle { } } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { - let result = parts - .next() - .map_or(Ok((Request::Idle(None), "")), |subsystems| { - let subsystems = subsystems - .split(',') - .map(|subsystem| SubSystem::from_str(subsystem).unwrap()) - .collect(); - Ok((Request::Idle(Some(subsystems)), "")) - }); + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { + let result = parts.next().map_or(Ok(None), |subsystems| { + let subsystems = subsystems + .split(',') + .map(|subsystem| SubSystem::from_str(subsystem).unwrap()) + .collect(); + Ok(Some(subsystems)) + }); debug_assert!(parts.next().is_none()); diff --git a/src/commands/querying_mpd_status/stats.rs b/src/commands/querying_mpd_status/stats.rs index 3a1e7af..8099b44 100644 --- a/src/commands/querying_mpd_status/stats.rs +++ b/src/commands/querying_mpd_status/stats.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, request_tokenizer::RequestTokenizer, response_tokenizer::{ ResponseAttributes, get_and_parse_optional_property, get_and_parse_property, @@ -32,10 +32,10 @@ impl Command for Stats { Self::COMMAND.to_string() } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { debug_assert!(parts.next().is_none()); - Ok((Request::Stats, "")) + Ok(()) } fn parse_response( diff --git a/src/commands/querying_mpd_status/status.rs b/src/commands/querying_mpd_status/status.rs index 828e900..1518454 100644 --- a/src/commands/querying_mpd_status/status.rs +++ b/src/commands/querying_mpd_status/status.rs @@ -4,12 +4,12 @@ use std::str::FromStr; use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::{Audio, BoolOrOneshot, SongId, SongPosition}, request_tokenizer::RequestTokenizer, response_tokenizer::{ - GenericResponseValue, ResponseAttributes, get_and_parse_optional_property, - get_and_parse_property, get_optional_property, get_property, + ResponseAttributes, get_and_parse_optional_property, get_and_parse_property, + get_optional_property, get_property, }, }; @@ -169,10 +169,10 @@ impl Command for Status { Self::COMMAND.to_string() } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { debug_assert!(parts.next().is_none()); - Ok((Request::Status, "")) + Ok(()) } fn parse_response( diff --git a/src/commands/queue/add.rs b/src/commands/queue/add.rs index f656608..51992d3 100644 --- a/src/commands/queue/add.rs +++ b/src/commands/queue/add.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::{SongPosition, Uri}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -33,7 +33,7 @@ impl Command for Add { } } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let uri = match parts.next() { Some(s) => s, None => return Err(RequestParserError::UnexpectedEOF), @@ -49,7 +49,10 @@ impl Command for Add { debug_assert!(parts.next().is_none()); - Ok((Request::Add(uri.to_string(), position), "")) + Ok(AddRequest { + uri: uri.to_string(), + position, + }) } fn parse_response( diff --git a/src/commands/queue/addid.rs b/src/commands/queue/addid.rs index 917cf9b..acfa147 100644 --- a/src/commands/queue/addid.rs +++ b/src/commands/queue/addid.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::{SongId, SongPosition, Uri}, request_tokenizer::RequestTokenizer, response_tokenizer::{ResponseAttributes, get_next_and_parse_property}, @@ -32,7 +32,7 @@ impl Command for AddId { } } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let uri = match parts.next() { Some(s) => s, None => return Err(RequestParserError::UnexpectedEOF), @@ -48,7 +48,10 @@ impl Command for AddId { debug_assert!(parts.next().is_none()); - Ok((Request::AddId(uri.to_string(), position), "")) + Ok(AddIdRequest { + uri: uri.to_string(), + position, + }) } fn parse_response( diff --git a/src/commands/queue/addtagid.rs b/src/commands/queue/addtagid.rs index 3b486ab..a327fd4 100644 --- a/src/commands/queue/addtagid.rs +++ b/src/commands/queue/addtagid.rs @@ -1,10 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - Request, - commands::{ - Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError, - }, + commands::{Command, RequestParserError, ResponseAttributes, ResponseParserError}, common::types::{SongId, TagName, TagValue}, request_tokenizer::RequestTokenizer, }; @@ -33,7 +30,7 @@ impl Command for AddTagId { ) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let songid = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let songid = songid .parse() @@ -51,7 +48,11 @@ impl Command for AddTagId { debug_assert!(parts.next().is_none()); - Ok((Request::AddTagId(songid, tag_name, tag_value), "")) + Ok(AddTagIdRequest { + songid, + tag_name, + tag_value, + }) } fn parse_response( diff --git a/src/commands/queue/clear.rs b/src/commands/queue/clear.rs index 12f40cb..e797701 100644 --- a/src/commands/queue/clear.rs +++ b/src/commands/queue/clear.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, }; @@ -15,9 +15,9 @@ impl Command for Clear { Self::COMMAND.to_string() } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { debug_assert!(parts.next().is_none()); - Ok((Request::Clear, "")) + Ok(()) } fn parse_response( diff --git a/src/commands/queue/cleartagid.rs b/src/commands/queue/cleartagid.rs index ab9e3ca..848acc0 100644 --- a/src/commands/queue/cleartagid.rs +++ b/src/commands/queue/cleartagid.rs @@ -1,8 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - Request, - commands::{Command, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::{SongId, TagName}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -25,7 +24,7 @@ impl Command for ClearTagId { format!("{} {} {}", Self::COMMAND, request.songid, request.tag_name) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let songid = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let songid = songid .parse() @@ -38,7 +37,7 @@ impl Command for ClearTagId { debug_assert!(parts.next().is_none()); - Ok((Request::ClearTagId(songid, tag_name), "")) + Ok(ClearTagIdRequest { songid, tag_name }) } fn parse_response( diff --git a/src/commands/queue/delete.rs b/src/commands/queue/delete.rs index 5d19894..9ffc552 100644 --- a/src/commands/queue/delete.rs +++ b/src/commands/queue/delete.rs @@ -1,8 +1,7 @@ use std::str::FromStr; use crate::{ - Request, - commands::{Command, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::OneOrRange, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -19,14 +18,14 @@ impl Command for Delete { format!("{} {}", Self::COMMAND, request) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let pos_or_range = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let one_or_range = OneOrRange::from_str(pos_or_range) .map_err(|_| RequestParserError::SyntaxError(0, pos_or_range.to_string()))?; debug_assert!(parts.next().is_none()); - Ok((Request::Delete(one_or_range), "")) + Ok(one_or_range) } fn parse_response( diff --git a/src/commands/queue/deleteid.rs b/src/commands/queue/deleteid.rs index d74c2ac..8e08298 100644 --- a/src/commands/queue/deleteid.rs +++ b/src/commands/queue/deleteid.rs @@ -1,6 +1,5 @@ use crate::{ - Request, - commands::{Command, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::SongId, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -17,7 +16,7 @@ impl Command for DeleteId { format!("{} {}", Self::COMMAND, request) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let id = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let id = id .parse() @@ -25,7 +24,7 @@ impl Command for DeleteId { debug_assert!(parts.next().is_none()); - Ok((Request::DeleteId(id), "")) + Ok(id) } fn parse_response( diff --git a/src/commands/queue/move_.rs b/src/commands/queue/move_.rs index ea8023a..44a3fa3 100644 --- a/src/commands/queue/move_.rs +++ b/src/commands/queue/move_.rs @@ -1,10 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - Request, - commands::{ - Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError, - }, + commands::{Command, RequestParserError, ResponseAttributes, ResponseParserError}, common::types::{AbsouluteRelativeSongPosition, OneOrRange}, request_tokenizer::RequestTokenizer, }; @@ -26,7 +23,7 @@ impl Command for Move { format!("{} {} {}", Self::COMMAND, request.from_or_range, request.to) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let from_or_range = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let from_or_range = from_or_range .parse() @@ -39,7 +36,7 @@ impl Command for Move { debug_assert!(parts.next().is_none()); - Ok((Request::Move(from_or_range, to), "")) + Ok(MoveRequest { from_or_range, to }) } fn parse_response( diff --git a/src/commands/queue/moveid.rs b/src/commands/queue/moveid.rs index bc56062..764e512 100644 --- a/src/commands/queue/moveid.rs +++ b/src/commands/queue/moveid.rs @@ -1,10 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - Request, - commands::{ - Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError, - }, + commands::{Command, RequestParserError, ResponseAttributes, ResponseParserError}, common::types::{AbsouluteRelativeSongPosition, SongId}, request_tokenizer::RequestTokenizer, }; @@ -26,7 +23,7 @@ impl Command for MoveId { format!("{} {} {}", Self::COMMAND, request.id, request.to) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let id = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let id = id .parse() @@ -39,7 +36,7 @@ impl Command for MoveId { debug_assert!(parts.next().is_none()); - Ok((Request::MoveId(id, to), "")) + Ok(MoveIdRequest { id, to }) } fn parse_response( diff --git a/src/commands/queue/playlist.rs b/src/commands/queue/playlist.rs index b8a9d39..59890ae 100644 --- a/src/commands/queue/playlist.rs +++ b/src/commands/queue/playlist.rs @@ -1,6 +1,5 @@ use crate::{ - Request, - commands::{Command, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, }; @@ -16,9 +15,9 @@ impl Command for Playlist { Self::COMMAND.to_string() } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { debug_assert!(parts.next().is_none()); - Ok((Request::Playlist, "")) + Ok(()) } fn parse_response( diff --git a/src/commands/queue/playlistfind.rs b/src/commands/queue/playlistfind.rs index 0c4ec94..b210606 100644 --- a/src/commands/queue/playlistfind.rs +++ b/src/commands/queue/playlistfind.rs @@ -1,8 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - Request, - commands::{Command, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::{Sort, WindowRange}, filter::Filter, request_tokenizer::RequestTokenizer, @@ -34,7 +33,7 @@ impl Command for PlaylistFind { cmd } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let filter = match parts.next() { Some(f) => { Filter::parse(f).map_err(|_| RequestParserError::SyntaxError(1, f.to_owned()))? @@ -64,7 +63,11 @@ impl Command for PlaylistFind { debug_assert!(parts.next().is_none()); - Ok((Request::PlaylistFind(filter, sort, window), "")) + Ok(PlaylistFindRequest { + filter, + sort, + window, + }) } fn parse_response( diff --git a/src/commands/queue/playlistid.rs b/src/commands/queue/playlistid.rs index d9a1f70..a742373 100644 --- a/src/commands/queue/playlistid.rs +++ b/src/commands/queue/playlistid.rs @@ -1,6 +1,5 @@ use crate::{ - Request, - commands::{Command, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::SongId, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -17,7 +16,7 @@ impl Command for PlaylistId { format!("{} {}", Self::COMMAND, request) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let id = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let id = id .parse() @@ -25,7 +24,7 @@ impl Command for PlaylistId { debug_assert!(parts.next().is_none()); - Ok((Request::PlaylistId(id), "")) + Ok(id) } fn parse_response( diff --git a/src/commands/queue/playlistinfo.rs b/src/commands/queue/playlistinfo.rs index c7ffa74..31890df 100644 --- a/src/commands/queue/playlistinfo.rs +++ b/src/commands/queue/playlistinfo.rs @@ -1,6 +1,5 @@ use crate::{ - Request, - commands::{Command, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::OneOrRange, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -20,7 +19,7 @@ impl Command for PlaylistInfo { } } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let one_or_range = parts .next() .map(|s| { @@ -31,7 +30,7 @@ impl Command for PlaylistInfo { debug_assert!(parts.next().is_none()); - Ok((Request::PlaylistInfo(one_or_range), "")) + Ok(one_or_range) } fn parse_response( diff --git a/src/commands/queue/playlistsearch.rs b/src/commands/queue/playlistsearch.rs index 0c4abf3..af7d981 100644 --- a/src/commands/queue/playlistsearch.rs +++ b/src/commands/queue/playlistsearch.rs @@ -1,8 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - Request, - commands::{Command, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::{Sort, WindowRange}, filter::Filter, request_tokenizer::RequestTokenizer, @@ -34,7 +33,7 @@ impl Command for PlaylistSearch { cmd } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let filter = match parts.next() { Some(f) => { Filter::parse(f).map_err(|_| RequestParserError::SyntaxError(1, f.to_owned()))? @@ -64,7 +63,11 @@ impl Command for PlaylistSearch { debug_assert!(parts.next().is_none()); - Ok((Request::PlaylistSearch(filter, sort, window), "")) + Ok(PlaylistSearchRequest { + filter, + sort, + window, + }) } fn parse_response( diff --git a/src/commands/queue/plchanges.rs b/src/commands/queue/plchanges.rs index 67ce9b8..b31aa63 100644 --- a/src/commands/queue/plchanges.rs +++ b/src/commands/queue/plchanges.rs @@ -1,8 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - Request, - commands::{Command, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::{PlaylistVersion, WindowRange}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -28,7 +27,7 @@ impl Command for PlChanges { } } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let version = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let version = version .parse() @@ -44,7 +43,7 @@ impl Command for PlChanges { debug_assert!(parts.next().is_none()); - Ok((Request::PlChanges(version, window), "")) + Ok(PlChangesRequest { version, window }) } fn parse_response( diff --git a/src/commands/queue/plchangesposid.rs b/src/commands/queue/plchangesposid.rs index a69f015..1d028d5 100644 --- a/src/commands/queue/plchangesposid.rs +++ b/src/commands/queue/plchangesposid.rs @@ -1,8 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - Request, - commands::{Command, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::{PlaylistVersion, WindowRange}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -28,7 +27,7 @@ impl Command for PlChangesPosId { } } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let version = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let version = version .parse() @@ -44,7 +43,7 @@ impl Command for PlChangesPosId { debug_assert!(parts.next().is_none()); - Ok((Request::PlChangesPosId(version, window), "")) + Ok(PlChangesPosIdRequest { version, window }) } fn parse_response( diff --git a/src/commands/queue/prio.rs b/src/commands/queue/prio.rs index d90bccd..7d27b8f 100644 --- a/src/commands/queue/prio.rs +++ b/src/commands/queue/prio.rs @@ -1,8 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - Request, - commands::{Command, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::{Priority, WindowRange}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -25,7 +24,7 @@ impl Command for Prio { format!("{} {} {}", Self::COMMAND, request.prio, request.window) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let prio = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let prio = prio .parse() @@ -38,7 +37,7 @@ impl Command for Prio { debug_assert!(parts.next().is_none()); - Ok((Request::Prio(prio, window), "")) + Ok(PrioRequest { prio, window }) } fn parse_response( diff --git a/src/commands/queue/prioid.rs b/src/commands/queue/prioid.rs index e1d218b..1a58b8d 100644 --- a/src/commands/queue/prioid.rs +++ b/src/commands/queue/prioid.rs @@ -1,8 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - Request, - commands::{Command, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::{Priority, SongId}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -31,7 +30,7 @@ impl Command for PrioId { format!("{} {} {}", Self::COMMAND, request.prio, songids) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let prio = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let prio = prio .parse() @@ -49,7 +48,7 @@ impl Command for PrioId { debug_assert!(parts.next().is_none()); - Ok((Request::PrioId(prio, songids), "")) + Ok(PrioIdRequest { prio, songids }) } fn parse_response( diff --git a/src/commands/queue/rangeid.rs b/src/commands/queue/rangeid.rs index 92faad4..f3d4924 100644 --- a/src/commands/queue/rangeid.rs +++ b/src/commands/queue/rangeid.rs @@ -1,8 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - Request, - commands::{Command, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::{SongId, TimeInterval}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -30,7 +29,7 @@ impl Command for RangeId { ) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let songid = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let songid = songid .parse() @@ -43,7 +42,10 @@ impl Command for RangeId { debug_assert!(parts.next().is_none()); - Ok((Request::RangeId(songid, time_interval), "")) + Ok(RangeIdRequest { + songid, + time_interval, + }) } fn parse_response( diff --git a/src/commands/queue/shuffle.rs b/src/commands/queue/shuffle.rs index 2cd2d38..5e8702a 100644 --- a/src/commands/queue/shuffle.rs +++ b/src/commands/queue/shuffle.rs @@ -1,6 +1,5 @@ use crate::{ - Request, - commands::{Command, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::OneOrRange, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -20,7 +19,7 @@ impl Command for Shuffle { } } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let range = parts .next() .map(|range| { @@ -32,7 +31,7 @@ impl Command for Shuffle { debug_assert!(parts.next().is_none()); - Ok((Request::Shuffle(range), "")) + Ok(range) } fn parse_response( diff --git a/src/commands/queue/swap.rs b/src/commands/queue/swap.rs index d8e333f..8128661 100644 --- a/src/commands/queue/swap.rs +++ b/src/commands/queue/swap.rs @@ -1,8 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - Request, - commands::{Command, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::SongPosition, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -30,7 +29,7 @@ impl Command for Swap { ) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let songpos1 = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let songpos1 = songpos1 .parse() @@ -43,7 +42,7 @@ impl Command for Swap { debug_assert!(parts.next().is_none()); - Ok((Request::Swap(songpos1, songpos2), "")) + Ok(SwapRequest { songpos1, songpos2 }) } fn parse_response( diff --git a/src/commands/queue/swapid.rs b/src/commands/queue/swapid.rs index d8d0ba9..2247485 100644 --- a/src/commands/queue/swapid.rs +++ b/src/commands/queue/swapid.rs @@ -1,8 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - Request, - commands::{Command, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::SongId, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -25,7 +24,7 @@ impl Command for SwapId { format!("{} {} {}", Self::COMMAND, request.songid1, request.songid2) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let songid1 = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let songid1 = songid1 .parse() @@ -38,7 +37,7 @@ impl Command for SwapId { debug_assert!(parts.next().is_none()); - Ok((Request::SwapId(songid1, songid2), "")) + Ok(SwapIdRequest { songid1, songid2 }) } fn parse_response( diff --git a/src/commands/reflection/commands.rs b/src/commands/reflection/commands.rs index 7bc21b8..526d875 100644 --- a/src/commands/reflection/commands.rs +++ b/src/commands/reflection/commands.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, request_tokenizer::RequestTokenizer, response_tokenizer::{ResponseAttributes, expect_property_type}, }; @@ -17,9 +17,9 @@ impl Command for Commands { Self::COMMAND.to_string() } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { debug_assert!(parts.next().is_none()); - Ok((Request::Commands, "")) + Ok(()) } fn parse_response( diff --git a/src/commands/reflection/config.rs b/src/commands/reflection/config.rs index 2f2ef99..deff963 100644 --- a/src/commands/reflection/config.rs +++ b/src/commands/reflection/config.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, request_tokenizer::RequestTokenizer, response_tokenizer::{ResponseAttributes, get_and_parse_property, get_property}, }; @@ -26,9 +26,9 @@ impl Command for Config { Self::COMMAND.to_string() } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { debug_assert!(parts.next().is_none()); - Ok((Request::Config, "")) + Ok(()) } fn parse_response( diff --git a/src/commands/reflection/decoders.rs b/src/commands/reflection/decoders.rs index f3b4339..c1a4ac3 100644 --- a/src/commands/reflection/decoders.rs +++ b/src/commands/reflection/decoders.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, request_tokenizer::RequestTokenizer, response_tokenizer::{ResponseAttributes, expect_property_type}, }; @@ -26,9 +26,9 @@ impl Command for Decoders { Self::COMMAND.to_string() } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { debug_assert!(parts.next().is_none()); - Ok((Request::Decoders, "")) + Ok(()) } fn parse_response( diff --git a/src/commands/reflection/not_commands.rs b/src/commands/reflection/not_commands.rs index 3371dc8..19399c4 100644 --- a/src/commands/reflection/not_commands.rs +++ b/src/commands/reflection/not_commands.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, request_tokenizer::RequestTokenizer, response_tokenizer::{ResponseAttributes, expect_property_type}, }; @@ -17,9 +17,9 @@ impl Command for NotCommands { Self::COMMAND.to_string() } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { debug_assert!(parts.next().is_none()); - Ok((Request::NotCommands, "")) + Ok(()) } fn parse_response( diff --git a/src/commands/reflection/url_handlers.rs b/src/commands/reflection/url_handlers.rs index 2bbbd24..fbca5f3 100644 --- a/src/commands/reflection/url_handlers.rs +++ b/src/commands/reflection/url_handlers.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, request_tokenizer::RequestTokenizer, response_tokenizer::{ResponseAttributes, expect_property_type}, }; @@ -17,9 +17,9 @@ impl Command for UrlHandlers { Self::COMMAND.to_string() } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { debug_assert!(parts.next().is_none()); - Ok((Request::UrlHandlers, "")) + Ok(()) } fn parse_response( diff --git a/src/commands/stickers/sticker_dec.rs b/src/commands/stickers/sticker_dec.rs index 285ee46..8bc8537 100644 --- a/src/commands/stickers/sticker_dec.rs +++ b/src/commands/stickers/sticker_dec.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::{StickerType, Uri}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -33,7 +33,7 @@ impl Command for StickerDec { ) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let sticker_type = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let sticker_type = sticker_type .parse() @@ -56,7 +56,12 @@ impl Command for StickerDec { debug_assert!(parts.next().is_none()); - Ok((Request::StickerDec(sticker_type, uri, name, value), "")) + Ok(StickerDecRequest { + sticker_type, + uri, + name, + value, + }) } fn parse_response( diff --git a/src/commands/stickers/sticker_delete.rs b/src/commands/stickers/sticker_delete.rs index 148fcf3..ddbe0be 100644 --- a/src/commands/stickers/sticker_delete.rs +++ b/src/commands/stickers/sticker_delete.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::{StickerType, Uri}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -31,7 +31,7 @@ impl Command for StickerDelete { ) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let sticker_type = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let sticker_type = sticker_type .parse() @@ -49,7 +49,11 @@ impl Command for StickerDelete { debug_assert!(parts.next().is_none()); - Ok((Request::StickerDelete(sticker_type, uri, name), "")) + Ok(StickerDeleteRequest { + sticker_type, + uri, + name, + }) } fn parse_response( diff --git a/src/commands/stickers/sticker_find.rs b/src/commands/stickers/sticker_find.rs index 12adbbf..274b0de 100644 --- a/src/commands/stickers/sticker_find.rs +++ b/src/commands/stickers/sticker_find.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::{Sort, StickerType, Uri, WindowRange}, request_tokenizer::RequestTokenizer, response_tokenizer::{ResponseAttributes, expect_property_type}, @@ -49,7 +49,7 @@ impl Command for StickerFind { cmd } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let sticker_type = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let sticker_type = sticker_type .parse() @@ -90,10 +90,13 @@ impl Command for StickerFind { debug_assert!(parts.next().is_none()); - Ok(( - Request::StickerFind(sticker_type, uri, name, sort, window), - "", - )) + Ok(StickerFindRequest { + sticker_type, + uri, + name, + sort, + window, + }) } fn parse_response( diff --git a/src/commands/stickers/sticker_get.rs b/src/commands/stickers/sticker_get.rs index 6fd65b4..9810e78 100644 --- a/src/commands/stickers/sticker_get.rs +++ b/src/commands/stickers/sticker_get.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::{StickerType, Uri}, request_tokenizer::RequestTokenizer, response_tokenizer::{ResponseAttributes, get_next_property}, @@ -33,7 +33,7 @@ impl Command for StickerGet { ) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let sticker_type = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let sticker_type = sticker_type .parse() @@ -51,7 +51,11 @@ impl Command for StickerGet { debug_assert!(parts.next().is_none()); - Ok((Request::StickerGet(sticker_type, uri, name), "")) + Ok(StickerGetRequest { + sticker_type, + uri, + name, + }) } fn parse_response( diff --git a/src/commands/stickers/sticker_inc.rs b/src/commands/stickers/sticker_inc.rs index 2ffc54a..68e348a 100644 --- a/src/commands/stickers/sticker_inc.rs +++ b/src/commands/stickers/sticker_inc.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::{StickerType, Uri}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -33,7 +33,7 @@ impl Command for StickerInc { ) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let sticker_type = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let sticker_type = sticker_type .parse() @@ -56,7 +56,12 @@ impl Command for StickerInc { debug_assert!(parts.next().is_none()); - Ok((Request::StickerInc(sticker_type, uri, name, value), "")) + Ok(StickerIncRequest { + sticker_type, + uri, + name, + value, + }) } fn parse_response( diff --git a/src/commands/stickers/sticker_list.rs b/src/commands/stickers/sticker_list.rs index e29d157..18b2856 100644 --- a/src/commands/stickers/sticker_list.rs +++ b/src/commands/stickers/sticker_list.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::{StickerType, Uri}, request_tokenizer::RequestTokenizer, response_tokenizer::{GenericResponseValue, ResponseAttributes}, @@ -28,7 +28,7 @@ impl Command for StickerList { format!("{} {} {}", Self::COMMAND, request.sticker_type, request.uri) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let sticker_type = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let sticker_type = sticker_type .parse() @@ -41,7 +41,7 @@ impl Command for StickerList { debug_assert!(parts.next().is_none()); - Ok((Request::StickerList(sticker_type, uri), "")) + Ok(StickerListRequest { sticker_type, uri }) } fn parse_response( diff --git a/src/commands/stickers/sticker_set.rs b/src/commands/stickers/sticker_set.rs index 697e0e0..2ed3afb 100644 --- a/src/commands/stickers/sticker_set.rs +++ b/src/commands/stickers/sticker_set.rs @@ -1,10 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - commands::{ - Command, Request, RequestParserError, RequestParserResult, ResponseAttributes, - ResponseParserError, - }, + commands::{Command, RequestParserError, ResponseAttributes, ResponseParserError}, common::types::{StickerType, Uri}, request_tokenizer::RequestTokenizer, }; @@ -35,7 +32,7 @@ impl Command for StickerSet { ) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let sticker_type = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let sticker_type = sticker_type .parse() @@ -58,7 +55,12 @@ impl Command for StickerSet { debug_assert!(parts.next().is_none()); - Ok((Request::StickerSet(sticker_type, uri, name, value), "")) + Ok(StickerSetRequest { + sticker_type, + uri, + name, + value, + }) } fn parse_response( diff --git a/src/commands/stickers/stickernames.rs b/src/commands/stickers/stickernames.rs index f13a7aa..9ccc30a 100644 --- a/src/commands/stickers/stickernames.rs +++ b/src/commands/stickers/stickernames.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, request_tokenizer::RequestTokenizer, response_tokenizer::{ResponseAttributes, expect_property_type}, }; @@ -17,10 +17,10 @@ impl Command for StickerNames { Self::COMMAND.to_string() } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { debug_assert!(parts.next().is_none()); - Ok((Request::StickerNames, "")) + Ok(()) } fn parse_response( diff --git a/src/commands/stickers/stickernamestypes.rs b/src/commands/stickers/stickernamestypes.rs index afd4676..a8cdb9f 100644 --- a/src/commands/stickers/stickernamestypes.rs +++ b/src/commands/stickers/stickernamestypes.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use crate::{ - commands::{Command, Request, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::StickerType, request_tokenizer::RequestTokenizer, response_tokenizer::{ResponseAttributes, expect_property_type}, @@ -12,20 +12,24 @@ pub struct StickerNamesTypes; pub type StickerNamesTypesResponse = HashMap>; impl Command for StickerNamesTypes { - type Request = StickerType; + type Request = Option; type Response = StickerNamesTypesResponse; const COMMAND: &'static str = "stickernamestypes"; fn serialize_request(&self, request: Self::Request) -> String { - format!("{} {}", Self::COMMAND, request) + if let Some(sticker_type) = request { + format!("{} {}", Self::COMMAND, sticker_type) + } else { + Self::COMMAND.to_string() + } } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let sticker_type = parts.next().map(|s| s.to_string()); debug_assert!(parts.next().is_none()); - Ok((Request::StickerNamesTypes(sticker_type), "")) + Ok(sticker_type) } fn parse_response( diff --git a/src/commands/stickers/stickertypes.rs b/src/commands/stickers/stickertypes.rs index 8cf5c84..1ddbd22 100644 --- a/src/commands/stickers/stickertypes.rs +++ b/src/commands/stickers/stickertypes.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, request_tokenizer::RequestTokenizer, response_tokenizer::{ResponseAttributes, expect_property_type}, }; @@ -17,10 +17,10 @@ impl Command for StickerTypes { Self::COMMAND.to_string() } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { debug_assert!(parts.next().is_none()); - Ok((Request::StickerTypes, "")) + Ok(()) } fn parse_response( diff --git a/src/commands/stored_playlists/listplaylist.rs b/src/commands/stored_playlists/listplaylist.rs index a5b93cf..10a8ae5 100644 --- a/src/commands/stored_playlists/listplaylist.rs +++ b/src/commands/stored_playlists/listplaylist.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::{PlaylistName, WindowRange}, request_tokenizer::RequestTokenizer, response_tokenizer::{ResponseAttributes, expect_property_type}, @@ -30,7 +30,7 @@ impl Command for ListPlaylist { } } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let name = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let name = name .parse::() @@ -46,7 +46,7 @@ impl Command for ListPlaylist { debug_assert!(parts.next().is_none()); - Ok((Request::ListPlaylist(name.to_string(), range), "")) + Ok(ListPlaylistRequest { name, range }) } fn parse_response( diff --git a/src/commands/stored_playlists/listplaylistinfo.rs b/src/commands/stored_playlists/listplaylistinfo.rs index 0c5ae73..1bbab7d 100644 --- a/src/commands/stored_playlists/listplaylistinfo.rs +++ b/src/commands/stored_playlists/listplaylistinfo.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::{PlaylistName, WindowRange}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -27,7 +27,7 @@ impl Command for ListPlaylistInfo { } } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let name = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let name = name .parse::() @@ -43,7 +43,7 @@ impl Command for ListPlaylistInfo { debug_assert!(parts.next().is_none()); - Ok((Request::ListPlaylistInfo(name, range), "")) + Ok(ListPlaylistInfoRequest { name, range }) } fn parse_response( diff --git a/src/commands/stored_playlists/listplaylists.rs b/src/commands/stored_playlists/listplaylists.rs index 0f860c5..a558a6d 100644 --- a/src/commands/stored_playlists/listplaylists.rs +++ b/src/commands/stored_playlists/listplaylists.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, }; @@ -15,9 +15,9 @@ impl Command for ListPlaylists { Self::COMMAND.to_string() } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { debug_assert!(parts.next().is_none()); - Ok((Request::ListPlaylists, "")) + Ok(()) } fn parse_response( diff --git a/src/commands/stored_playlists/load.rs b/src/commands/stored_playlists/load.rs index 934147e..c4ee3ec 100644 --- a/src/commands/stored_playlists/load.rs +++ b/src/commands/stored_playlists/load.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::{PlaylistName, SongPosition, WindowRange}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -38,7 +38,7 @@ impl Command for Load { } } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let playlist_name = parts .next() .ok_or(RequestParserError::UnexpectedEOF)? @@ -63,7 +63,11 @@ impl Command for Load { debug_assert!(parts.next().is_none()); - Ok((Request::Load(playlist_name, range, pos), "")) + Ok(LoadRequest { + name: playlist_name, + range, + position: pos, + }) } fn parse_response( diff --git a/src/commands/stored_playlists/playlistadd.rs b/src/commands/stored_playlists/playlistadd.rs index a5c240f..3ab9a2c 100644 --- a/src/commands/stored_playlists/playlistadd.rs +++ b/src/commands/stored_playlists/playlistadd.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::{PlaylistName, SongPosition, Uri}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -43,7 +43,7 @@ impl Command for PlaylistAdd { } } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let playlist_name = parts .next() .ok_or(RequestParserError::UnexpectedEOF)? @@ -64,7 +64,11 @@ impl Command for PlaylistAdd { debug_assert!(parts.next().is_none()); - Ok((Request::PlaylistAdd(playlist_name, uri, position), "")) + Ok(PlaylistAddRequest { + playlist_name, + uri, + position, + }) } fn parse_response( diff --git a/src/commands/stored_playlists/playlistclear.rs b/src/commands/stored_playlists/playlistclear.rs index 3df8027..06a746a 100644 --- a/src/commands/stored_playlists/playlistclear.rs +++ b/src/commands/stored_playlists/playlistclear.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::PlaylistName, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -16,7 +16,7 @@ impl Command for PlaylistClear { format!("{} {}", Self::COMMAND, request) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let playlist_name = parts .next() .ok_or(RequestParserError::UnexpectedEOF)? @@ -24,7 +24,7 @@ impl Command for PlaylistClear { debug_assert!(parts.next().is_none()); - Ok((Request::PlaylistClear(playlist_name), "")) + Ok(playlist_name) } fn parse_response( diff --git a/src/commands/stored_playlists/playlistdelete.rs b/src/commands/stored_playlists/playlistdelete.rs index 549bdfd..2d3e109 100644 --- a/src/commands/stored_playlists/playlistdelete.rs +++ b/src/commands/stored_playlists/playlistdelete.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::{OneOrRange, PlaylistName}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -29,7 +29,7 @@ impl Command for PlaylistDelete { ) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let playlist_name = parts .next() .ok_or(RequestParserError::UnexpectedEOF)? @@ -43,7 +43,10 @@ impl Command for PlaylistDelete { debug_assert!(parts.next().is_none()); - Ok((Request::PlaylistDelete(playlist_name, position), "")) + Ok(PlaylistDeleteRequest { + playlist_name: playlist_name, + position, + }) } fn parse_response( diff --git a/src/commands/stored_playlists/playlistlength.rs b/src/commands/stored_playlists/playlistlength.rs index 8414741..892776e 100644 --- a/src/commands/stored_playlists/playlistlength.rs +++ b/src/commands/stored_playlists/playlistlength.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::PlaylistName, request_tokenizer::RequestTokenizer, response_tokenizer::{ResponseAttributes, get_and_parse_property}, @@ -26,7 +26,7 @@ impl Command for PlaylistLength { format!("{} {}", Self::COMMAND, request) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let playlist_name = parts .next() .ok_or(RequestParserError::UnexpectedEOF)? @@ -34,7 +34,7 @@ impl Command for PlaylistLength { debug_assert!(parts.next().is_none()); - Ok((Request::PlaylistLength(playlist_name), "")) + Ok(playlist_name) } fn parse_response( diff --git a/src/commands/stored_playlists/playlistmove.rs b/src/commands/stored_playlists/playlistmove.rs index 690be20..df53144 100644 --- a/src/commands/stored_playlists/playlistmove.rs +++ b/src/commands/stored_playlists/playlistmove.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::{OneOrRange, PlaylistName, SongPosition}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -38,7 +38,7 @@ impl Command for PlaylistMove { } } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let playlist_name = parts .next() .ok_or(RequestParserError::UnexpectedEOF)? @@ -63,7 +63,11 @@ impl Command for PlaylistMove { .map_err(|_| RequestParserError::SyntaxError(0, from_or_range_or_to.to_string()))? }; - Ok((Request::PlaylistMove(playlist_name, from, to), "")) + Ok(PlaylistMoveRequest { + playlist_name, + from, + to, + }) } fn parse_response( diff --git a/src/commands/stored_playlists/rename.rs b/src/commands/stored_playlists/rename.rs index 2aa66f8..e1579d8 100644 --- a/src/commands/stored_playlists/rename.rs +++ b/src/commands/stored_playlists/rename.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, }; @@ -28,7 +28,7 @@ impl Command for Rename { ) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let old_name = parts .next() .ok_or(RequestParserError::UnexpectedEOF)? @@ -41,7 +41,7 @@ impl Command for Rename { debug_assert!(parts.next().is_none()); - Ok((Request::Rename(old_name, new_name), "")) + Ok(RenameRequest { old_name, new_name }) } fn parse_response( diff --git a/src/commands/stored_playlists/rm.rs b/src/commands/stored_playlists/rm.rs index 1cb2d2b..7032ada 100644 --- a/src/commands/stored_playlists/rm.rs +++ b/src/commands/stored_playlists/rm.rs @@ -1,5 +1,5 @@ use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::PlaylistName, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -16,7 +16,7 @@ impl Command for Rm { format!("{} {}", Self::COMMAND, request) } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let playlist_name = parts .next() .ok_or(RequestParserError::UnexpectedEOF)? @@ -24,7 +24,7 @@ impl Command for Rm { debug_assert!(parts.next().is_none()); - Ok((Request::Rm(playlist_name), "")) + Ok(playlist_name) } fn parse_response( diff --git a/src/commands/stored_playlists/save.rs b/src/commands/stored_playlists/save.rs index a5b334e..f962428 100644 --- a/src/commands/stored_playlists/save.rs +++ b/src/commands/stored_playlists/save.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::{PlaylistName, SaveMode}, request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes, @@ -31,7 +31,7 @@ impl Command for Save { } } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let playlist_name = parts .next() .ok_or(RequestParserError::UnexpectedEOF)? @@ -47,7 +47,10 @@ impl Command for Save { debug_assert!(parts.next().is_none()); - Ok((Request::Save(playlist_name, mode), "")) + Ok(SaveRequest { + playlist_name, + mode, + }) } fn parse_response( diff --git a/src/commands/stored_playlists/searchplaylist.rs b/src/commands/stored_playlists/searchplaylist.rs index e0862be..72cb6b9 100644 --- a/src/commands/stored_playlists/searchplaylist.rs +++ b/src/commands/stored_playlists/searchplaylist.rs @@ -1,7 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::{ - commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError}, + commands::{Command, RequestParserError, ResponseParserError}, common::types::{PlaylistName, WindowRange}, filter::Filter, request_tokenizer::RequestTokenizer, @@ -26,7 +26,7 @@ impl Command for SearchPlaylist { unimplemented!() } - fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> { + fn parse_request(mut parts: RequestTokenizer<'_>) -> Result { let name = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let name = name .parse::() @@ -49,7 +49,11 @@ impl Command for SearchPlaylist { debug_assert!(parts.next().is_none()); - Ok((Request::SearchPlaylist(name, filter, range), "")) + Ok(SearchPlaylistRequest { + name, + filter, + range, + }) } fn parse_response( diff --git a/src/lib.rs b/src/lib.rs index 6eb61f5..fb6da45 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -15,3 +15,6 @@ mod server; pub use request::Request; pub use response::Response; pub use server::MPDServer; + +pub use common::types::*; +pub use filter::{CaseSensitivity, ComparisonOperator, Filter}; diff --git a/src/request.rs b/src/request.rs index 47a9e90..22538cc 100644 --- a/src/request.rs +++ b/src/request.rs @@ -1,9 +1,7 @@ use serde::{Deserialize, Serialize}; use crate::common::types::*; -use crate::request_tokenizer::RequestTokenizer; -use crate::commands::*; use crate::filter::Filter; // TODO: SingleLineString @@ -204,6 +202,8 @@ pub enum Request { SendMessage(ChannelName, String), } +impl Request { + // pub enum RequestParserError { // SyntaxError(u64, String), // MissingCommandListEnd(u64), @@ -218,200 +218,200 @@ pub enum Request { // could skip stuff internally? Or do we want to report back the error with the entire command // and let the library user decide what to do? -impl Request { - pub fn parse_next(raw: &str) -> RequestParserResult<'_> { - let (line, rest) = raw - .split_once('\n') - .ok_or(RequestParserError::UnexpectedEOF)?; - let mut parts = RequestTokenizer::new(line); +// impl Request { + // pub fn parse_next(raw: &str) -> Result { + // let (line, rest) = raw + // .split_once('\n') + // .ok_or(RequestParserError::UnexpectedEOF)?; + // let mut parts = RequestTokenizer::new(line); - match parts - .next() - .ok_or(RequestParserError::SyntaxError(0, line.to_string()))? - .trim() - { - "command_list_begin" => { - let mut commands = Vec::new(); - let mut i = 1; - loop { - i += 1; - let (line, rest) = rest - .split_once('\n') - .ok_or(RequestParserError::MissingCommandListEnd(i))?; - match line.trim() { - "command_list_begin" => { - return Err(RequestParserError::NestedCommandList(i)); - } - "command_list_end" => { - return Ok((Request::CommandList(commands), rest)); - } - input => { - let (command, _) = Request::parse_next(input)?; - commands.push(command); - } - } - } - } - "command_list_end" => Err(RequestParserError::UnexpectedCommandListEnd(0)), + // match parts + // .next() + // .ok_or(RequestParserError::SyntaxError(0, line.to_string()))? + // .trim() + // { + // "command_list_begin" => { + // let mut commands = Vec::new(); + // let mut i = 1; + // loop { + // i += 1; + // let (line, rest) = rest + // .split_once('\n') + // .ok_or(RequestParserError::MissingCommandListEnd(i))?; + // match line.trim() { + // "command_list_begin" => { + // return Err(RequestParserError::NestedCommandList(i)); + // } + // "command_list_end" => { + // return Ok((Request::CommandList(commands), rest)); + // } + // input => { + // let (command, _) = Request::parse_next(input)?; + // commands.push(command); + // } + // } + // } + // } + // "command_list_end" => Err(RequestParserError::UnexpectedCommandListEnd(0)), - /* querying mpd status */ - ClearError::COMMAND => ClearError::parse_request(parts), - CurrentSong::COMMAND => CurrentSong::parse_request(parts), - Idle::COMMAND => Idle::parse_request(parts), - Status::COMMAND => Status::parse_request(parts), - Stats::COMMAND => Stats::parse_request(parts), + // /* querying mpd status */ + // ClearError::COMMAND => ClearError::parse_request(parts), + // CurrentSong::COMMAND => CurrentSong::parse_request(parts), + // Idle::COMMAND => Idle::parse_request(parts), + // Status::COMMAND => Status::parse_request(parts), + // Stats::COMMAND => Stats::parse_request(parts), - /* playback options */ - Consume::COMMAND => Consume::parse_request(parts), - Crossfade::COMMAND => Crossfade::parse_request(parts), - MixRampDb::COMMAND => MixRampDb::parse_request(parts), - MixRampDelay::COMMAND => MixRampDelay::parse_request(parts), - Random::COMMAND => Random::parse_request(parts), - Repeat::COMMAND => Repeat::parse_request(parts), - SetVol::COMMAND => SetVol::parse_request(parts), - GetVol::COMMAND => GetVol::parse_request(parts), - Single::COMMAND => Single::parse_request(parts), - ReplayGainMode::COMMAND => ReplayGainMode::parse_request(parts), - ReplayGainStatus::COMMAND => ReplayGainStatus::parse_request(parts), - Volume::COMMAND => Volume::parse_request(parts), + // /* playback options */ + // Consume::COMMAND => Consume::parse_request(parts), + // Crossfade::COMMAND => Crossfade::parse_request(parts), + // MixRampDb::COMMAND => MixRampDb::parse_request(parts), + // MixRampDelay::COMMAND => MixRampDelay::parse_request(parts), + // Random::COMMAND => Random::parse_request(parts), + // Repeat::COMMAND => Repeat::parse_request(parts), + // SetVol::COMMAND => SetVol::parse_request(parts), + // GetVol::COMMAND => GetVol::parse_request(parts), + // Single::COMMAND => Single::parse_request(parts), + // ReplayGainMode::COMMAND => ReplayGainMode::parse_request(parts), + // ReplayGainStatus::COMMAND => ReplayGainStatus::parse_request(parts), + // Volume::COMMAND => Volume::parse_request(parts), - /* playback control */ - Next::COMMAND => Next::parse_request(parts), - Pause::COMMAND => Pause::parse_request(parts), - Play::COMMAND => Play::parse_request(parts), - PlayId::COMMAND => PlayId::parse_request(parts), - Previous::COMMAND => Previous::parse_request(parts), - Seek::COMMAND => Seek::parse_request(parts), - SeekId::COMMAND => SeekId::parse_request(parts), - SeekCur::COMMAND => SeekCur::parse_request(parts), - Stop::COMMAND => Stop::parse_request(parts), + // /* playback control */ + // Next::COMMAND => Next::parse_request(parts), + // Pause::COMMAND => Pause::parse_request(parts), + // Play::COMMAND => Play::parse_request(parts), + // PlayId::COMMAND => PlayId::parse_request(parts), + // Previous::COMMAND => Previous::parse_request(parts), + // Seek::COMMAND => Seek::parse_request(parts), + // SeekId::COMMAND => SeekId::parse_request(parts), + // SeekCur::COMMAND => SeekCur::parse_request(parts), + // Stop::COMMAND => Stop::parse_request(parts), - /* queue */ - Add::COMMAND => Add::parse_request(parts), - AddId::COMMAND => AddId::parse_request(parts), - Clear::COMMAND => Clear::parse_request(parts), - Delete::COMMAND => Delete::parse_request(parts), - DeleteId::COMMAND => DeleteId::parse_request(parts), - Move::COMMAND => Move::parse_request(parts), - MoveId::COMMAND => MoveId::parse_request(parts), - Playlist::COMMAND => Playlist::parse_request(parts), - PlaylistFind::COMMAND => PlaylistFind::parse_request(parts), - PlaylistId::COMMAND => PlaylistId::parse_request(parts), - PlaylistInfo::COMMAND => PlaylistInfo::parse_request(parts), - PlaylistSearch::COMMAND => PlaylistSearch::parse_request(parts), - PlChanges::COMMAND => PlChanges::parse_request(parts), - PlChangesPosId::COMMAND => PlChangesPosId::parse_request(parts), - Prio::COMMAND => Prio::parse_request(parts), - PrioId::COMMAND => PrioId::parse_request(parts), - RangeId::COMMAND => RangeId::parse_request(parts), - Shuffle::COMMAND => Shuffle::parse_request(parts), - Swap::COMMAND => Swap::parse_request(parts), - SwapId::COMMAND => SwapId::parse_request(parts), - AddTagId::COMMAND => AddTagId::parse_request(parts), - ClearTagId::COMMAND => ClearTagId::parse_request(parts), + // /* queue */ + // Add::COMMAND => Add::parse_request(parts), + // AddId::COMMAND => AddId::parse_request(parts), + // Clear::COMMAND => Clear::parse_request(parts), + // Delete::COMMAND => Delete::parse_request(parts), + // DeleteId::COMMAND => DeleteId::parse_request(parts), + // Move::COMMAND => Move::parse_request(parts), + // MoveId::COMMAND => MoveId::parse_request(parts), + // Playlist::COMMAND => Playlist::parse_request(parts), + // PlaylistFind::COMMAND => PlaylistFind::parse_request(parts), + // PlaylistId::COMMAND => PlaylistId::parse_request(parts), + // PlaylistInfo::COMMAND => PlaylistInfo::parse_request(parts), + // PlaylistSearch::COMMAND => PlaylistSearch::parse_request(parts), + // PlChanges::COMMAND => PlChanges::parse_request(parts), + // PlChangesPosId::COMMAND => PlChangesPosId::parse_request(parts), + // Prio::COMMAND => Prio::parse_request(parts), + // PrioId::COMMAND => PrioId::parse_request(parts), + // RangeId::COMMAND => RangeId::parse_request(parts), + // Shuffle::COMMAND => Shuffle::parse_request(parts), + // Swap::COMMAND => Swap::parse_request(parts), + // SwapId::COMMAND => SwapId::parse_request(parts), + // AddTagId::COMMAND => AddTagId::parse_request(parts), + // ClearTagId::COMMAND => ClearTagId::parse_request(parts), - /* stored playlists */ - ListPlaylist::COMMAND => ListPlaylist::parse_request(parts), - ListPlaylistInfo::COMMAND => ListPlaylistInfo::parse_request(parts), - SearchPlaylist::COMMAND => SearchPlaylist::parse_request(parts), - ListPlaylists::COMMAND => ListPlaylists::parse_request(parts), - Load::COMMAND => Load::parse_request(parts), - PlaylistAdd::COMMAND => PlaylistAdd::parse_request(parts), - PlaylistClear::COMMAND => PlaylistClear::parse_request(parts), - PlaylistDelete::COMMAND => PlaylistDelete::parse_request(parts), - PlaylistLength::COMMAND => PlaylistLength::parse_request(parts), - PlaylistMove::COMMAND => PlaylistMove::parse_request(parts), - Rename::COMMAND => Rename::parse_request(parts), - Rm::COMMAND => Rm::parse_request(parts), - Save::COMMAND => Save::parse_request(parts), + // /* stored playlists */ + // ListPlaylist::COMMAND => ListPlaylist::parse_request(parts), + // ListPlaylistInfo::COMMAND => ListPlaylistInfo::parse_request(parts), + // SearchPlaylist::COMMAND => SearchPlaylist::parse_request(parts), + // ListPlaylists::COMMAND => ListPlaylists::parse_request(parts), + // Load::COMMAND => Load::parse_request(parts), + // PlaylistAdd::COMMAND => PlaylistAdd::parse_request(parts), + // PlaylistClear::COMMAND => PlaylistClear::parse_request(parts), + // PlaylistDelete::COMMAND => PlaylistDelete::parse_request(parts), + // PlaylistLength::COMMAND => PlaylistLength::parse_request(parts), + // PlaylistMove::COMMAND => PlaylistMove::parse_request(parts), + // Rename::COMMAND => Rename::parse_request(parts), + // Rm::COMMAND => Rm::parse_request(parts), + // Save::COMMAND => Save::parse_request(parts), - /* music database */ - AlbumArt::COMMAND => AlbumArt::parse_request(parts), - Count::COMMAND => Count::parse_request(parts), - GetFingerprint::COMMAND => GetFingerprint::parse_request(parts), - Find::COMMAND => Find::parse_request(parts), - FindAdd::COMMAND => FindAdd::parse_request(parts), - List::COMMAND => List::parse_request(parts), - ListAll::COMMAND => ListAll::parse_request(parts), - ListAllInfo::COMMAND => ListAllInfo::parse_request(parts), - ListFiles::COMMAND => ListFiles::parse_request(parts), - LsInfo::COMMAND => LsInfo::parse_request(parts), - ReadComments::COMMAND => ReadComments::parse_request(parts), - ReadPicture::COMMAND => ReadPicture::parse_request(parts), - Search::COMMAND => Search::parse_request(parts), - SearchAdd::COMMAND => SearchAdd::parse_request(parts), - SearchAddPl::COMMAND => SearchAddPl::parse_request(parts), - SearchCount::COMMAND => SearchCount::parse_request(parts), - Update::COMMAND => Update::parse_request(parts), - Rescan::COMMAND => Rescan::parse_request(parts), + // /* music database */ + // AlbumArt::COMMAND => AlbumArt::parse_request(parts), + // Count::COMMAND => Count::parse_request(parts), + // GetFingerprint::COMMAND => GetFingerprint::parse_request(parts), + // Find::COMMAND => Find::parse_request(parts), + // FindAdd::COMMAND => FindAdd::parse_request(parts), + // List::COMMAND => List::parse_request(parts), + // ListAll::COMMAND => ListAll::parse_request(parts), + // ListAllInfo::COMMAND => ListAllInfo::parse_request(parts), + // ListFiles::COMMAND => ListFiles::parse_request(parts), + // LsInfo::COMMAND => LsInfo::parse_request(parts), + // ReadComments::COMMAND => ReadComments::parse_request(parts), + // ReadPicture::COMMAND => ReadPicture::parse_request(parts), + // Search::COMMAND => Search::parse_request(parts), + // SearchAdd::COMMAND => SearchAdd::parse_request(parts), + // SearchAddPl::COMMAND => SearchAddPl::parse_request(parts), + // SearchCount::COMMAND => SearchCount::parse_request(parts), + // Update::COMMAND => Update::parse_request(parts), + // Rescan::COMMAND => Rescan::parse_request(parts), - /* mounts and neighbors */ - Mount::COMMAND => Mount::parse_request(parts), - Unmount::COMMAND => Unmount::parse_request(parts), - ListMounts::COMMAND => ListMounts::parse_request(parts), - ListNeighbors::COMMAND => ListNeighbors::parse_request(parts), + // /* mounts and neighbors */ + // Mount::COMMAND => Mount::parse_request(parts), + // Unmount::COMMAND => Unmount::parse_request(parts), + // ListMounts::COMMAND => ListMounts::parse_request(parts), + // ListNeighbors::COMMAND => ListNeighbors::parse_request(parts), - /* stickers */ - StickerGet::COMMAND => StickerGet::parse_request(parts), - StickerSet::COMMAND => StickerSet::parse_request(parts), - StickerInc::COMMAND => StickerInc::parse_request(parts), - StickerDec::COMMAND => StickerDec::parse_request(parts), - StickerDelete::COMMAND => StickerDelete::parse_request(parts), - StickerList::COMMAND => StickerList::parse_request(parts), - StickerFind::COMMAND => StickerFind::parse_request(parts), - StickerNames::COMMAND => StickerNames::parse_request(parts), - StickerTypes::COMMAND => StickerTypes::parse_request(parts), - StickerNamesTypes::COMMAND => StickerNamesTypes::parse_request(parts), + // /* stickers */ + // StickerGet::COMMAND => StickerGet::parse_request(parts), + // StickerSet::COMMAND => StickerSet::parse_request(parts), + // StickerInc::COMMAND => StickerInc::parse_request(parts), + // StickerDec::COMMAND => StickerDec::parse_request(parts), + // StickerDelete::COMMAND => StickerDelete::parse_request(parts), + // StickerList::COMMAND => StickerList::parse_request(parts), + // StickerFind::COMMAND => StickerFind::parse_request(parts), + // StickerNames::COMMAND => StickerNames::parse_request(parts), + // StickerTypes::COMMAND => StickerTypes::parse_request(parts), + // StickerNamesTypes::COMMAND => StickerNamesTypes::parse_request(parts), - /* connection settings */ - Close::COMMAND => Close::parse_request(parts), - Kill::COMMAND => Kill::parse_request(parts), - Password::COMMAND => Password::parse_request(parts), - Ping::COMMAND => Ping::parse_request(parts), - BinaryLimit::COMMAND => BinaryLimit::parse_request(parts), - TagTypes::COMMAND => TagTypes::parse_request(parts), - TagTypesDisable::COMMAND => TagTypesDisable::parse_request(parts), - TagTypesEnable::COMMAND => TagTypesEnable::parse_request(parts), - TagTypesClear::COMMAND => TagTypesClear::parse_request(parts), - TagTypesAll::COMMAND => TagTypesAll::parse_request(parts), - TagTypesAvailable::COMMAND => TagTypesAvailable::parse_request(parts), - TagTypesReset::COMMAND => TagTypesReset::parse_request(parts), - Protocol::COMMAND => Protocol::parse_request(parts), - ProtocolDisable::COMMAND => ProtocolDisable::parse_request(parts), - ProtocolEnable::COMMAND => ProtocolEnable::parse_request(parts), - ProtocolClear::COMMAND => ProtocolClear::parse_request(parts), - ProtocolAll::COMMAND => ProtocolAll::parse_request(parts), - ProtocolAvailable::COMMAND => ProtocolAvailable::parse_request(parts), + // /* connection settings */ + // Close::COMMAND => Close::parse_request(parts), + // Kill::COMMAND => Kill::parse_request(parts), + // Password::COMMAND => Password::parse_request(parts), + // Ping::COMMAND => Ping::parse_request(parts), + // BinaryLimit::COMMAND => BinaryLimit::parse_request(parts), + // TagTypes::COMMAND => TagTypes::parse_request(parts), + // TagTypesDisable::COMMAND => TagTypesDisable::parse_request(parts), + // TagTypesEnable::COMMAND => TagTypesEnable::parse_request(parts), + // TagTypesClear::COMMAND => TagTypesClear::parse_request(parts), + // TagTypesAll::COMMAND => TagTypesAll::parse_request(parts), + // TagTypesAvailable::COMMAND => TagTypesAvailable::parse_request(parts), + // TagTypesReset::COMMAND => TagTypesReset::parse_request(parts), + // Protocol::COMMAND => Protocol::parse_request(parts), + // ProtocolDisable::COMMAND => ProtocolDisable::parse_request(parts), + // ProtocolEnable::COMMAND => ProtocolEnable::parse_request(parts), + // ProtocolClear::COMMAND => ProtocolClear::parse_request(parts), + // ProtocolAll::COMMAND => ProtocolAll::parse_request(parts), + // ProtocolAvailable::COMMAND => ProtocolAvailable::parse_request(parts), - /* partition commands */ - Partition::COMMAND => Partition::parse_request(parts), - ListPartitions::COMMAND => ListPartitions::parse_request(parts), - NewPartition::COMMAND => NewPartition::parse_request(parts), - DelPartition::COMMAND => DelPartition::parse_request(parts), - MoveOutput::COMMAND => MoveOutput::parse_request(parts), + // /* partition commands */ + // Partition::COMMAND => Partition::parse_request(parts), + // ListPartitions::COMMAND => ListPartitions::parse_request(parts), + // NewPartition::COMMAND => NewPartition::parse_request(parts), + // DelPartition::COMMAND => DelPartition::parse_request(parts), + // MoveOutput::COMMAND => MoveOutput::parse_request(parts), - /* audio output devices */ - DisableOutput::COMMAND => DisableOutput::parse_request(parts), - EnableOutput::COMMAND => EnableOutput::parse_request(parts), - ToggleOutput::COMMAND => ToggleOutput::parse_request(parts), - Outputs::COMMAND => Outputs::parse_request(parts), - OutputSet::COMMAND => OutputSet::parse_request(parts), + // /* audio output devices */ + // DisableOutput::COMMAND => DisableOutput::parse_request(parts), + // EnableOutput::COMMAND => EnableOutput::parse_request(parts), + // ToggleOutput::COMMAND => ToggleOutput::parse_request(parts), + // Outputs::COMMAND => Outputs::parse_request(parts), + // OutputSet::COMMAND => OutputSet::parse_request(parts), - /* reflection */ - Config::COMMAND => Config::parse_request(parts), - Commands::COMMAND => Commands::parse_request(parts), - NotCommands::COMMAND => NotCommands::parse_request(parts), - UrlHandlers::COMMAND => UrlHandlers::parse_request(parts), - Decoders::COMMAND => Decoders::parse_request(parts), + // /* reflection */ + // Config::COMMAND => Config::parse_request(parts), + // Commands::COMMAND => Commands::parse_request(parts), + // NotCommands::COMMAND => NotCommands::parse_request(parts), + // UrlHandlers::COMMAND => UrlHandlers::parse_request(parts), + // Decoders::COMMAND => Decoders::parse_request(parts), - /* client to client */ - Subscribe::COMMAND => Subscribe::parse_request(parts), - Unsubscribe::COMMAND => Unsubscribe::parse_request(parts), - Channels::COMMAND => Channels::parse_request(parts), - ReadMessages::COMMAND => ReadMessages::parse_request(parts), - SendMessage::COMMAND => SendMessage::parse_request(parts), + // /* client to client */ + // Subscribe::COMMAND => Subscribe::parse_request(parts), + // Unsubscribe::COMMAND => Unsubscribe::parse_request(parts), + // Channels::COMMAND => Channels::parse_request(parts), + // ReadMessages::COMMAND => ReadMessages::parse_request(parts), + // SendMessage::COMMAND => SendMessage::parse_request(parts), - _ => unimplemented!(), - } - } + // _ => unimplemented!(), + // } + // } }