commands: remove Command for bi-directional assoc types
Also add a `serialize` stub for responses
This commit is contained in:
+4
-5
@@ -106,9 +106,9 @@ where
|
||||
Ok(response)
|
||||
}
|
||||
|
||||
pub async fn execute<C>(&mut self, request: C::Request) -> Result<C::Response, MpdClientError>
|
||||
pub async fn execute<R>(&mut self, request: R) -> Result<R::Response, MpdClientError>
|
||||
where
|
||||
C: Command,
|
||||
R: CommandRequest,
|
||||
{
|
||||
let payload = request.serialize();
|
||||
|
||||
@@ -123,7 +123,7 @@ where
|
||||
.map_err(MpdClientError::ConnectionError)?;
|
||||
|
||||
let response_bytes = self.read_response().await?;
|
||||
let response = C::Response::parse_raw(&response_bytes)?;
|
||||
let response = R::Response::parse_raw(&response_bytes)?;
|
||||
|
||||
Ok(response)
|
||||
}
|
||||
@@ -132,7 +132,6 @@ where
|
||||
&mut self,
|
||||
position: Option<SongPosition>,
|
||||
) -> Result<PlayResponse, MpdClientError> {
|
||||
let request = <Play as Command>::Request::new(position);
|
||||
self.execute::<Play>(request).await
|
||||
self.execute(PlayRequest::new(position)).await
|
||||
}
|
||||
}
|
||||
|
||||
+174
-170
@@ -2,10 +2,6 @@
|
||||
//!
|
||||
//! An mpd command consists of a pair of serializers and parsers for both the request
|
||||
//! and the corresponding response, as well as the command name used to identify the command.
|
||||
//!
|
||||
//! Each command is modelled as a struct implementing the [`Command`] trait,
|
||||
//! which in turn uses the [`CommandRequest`] and [`CommandResponse`] traits
|
||||
//! to define the request and response types respectively.
|
||||
|
||||
use crate::{request_tokenizer::RequestTokenizer, response_tokenizer::ResponseAttributes};
|
||||
|
||||
@@ -45,6 +41,9 @@ pub trait CommandRequest
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
/// The response type produced by the server when this request is executed.
|
||||
type Response: CommandResponse;
|
||||
|
||||
/// The command name used within the protocol
|
||||
const COMMAND: &'static str;
|
||||
|
||||
@@ -133,8 +132,8 @@ pub trait CommandResponse
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
// /// Serializes the response into a Vec<u8>.
|
||||
// fn serialize(&self) -> Vec<u8>;
|
||||
/// The request type that provokes this response.
|
||||
type Request: CommandRequest<Response = Self>;
|
||||
|
||||
/// Parses the response from its tokenized parts.
|
||||
/// See also [`parse_raw`].
|
||||
@@ -144,40 +143,11 @@ where
|
||||
fn parse_raw(raw: &[u8]) -> Result<Self, ResponseParserError> {
|
||||
Self::parse(ResponseAttributes::new_from_bytes(raw))
|
||||
}
|
||||
}
|
||||
|
||||
/// A trait modelling the request/response pair of a single MPD command.
|
||||
pub trait Command {
|
||||
/// The request sent from the client to the server
|
||||
type Request: CommandRequest;
|
||||
/// The response sent from the server to the client
|
||||
type Response: CommandResponse;
|
||||
|
||||
/// The command name used within the protocol
|
||||
const COMMAND: &'static str = Self::Request::COMMAND;
|
||||
|
||||
/// Parse the request from its tokenized parts. See also [`parse_raw_request`].
|
||||
fn parse_request(parts: RequestTokenizer) -> Result<Self::Request, RequestParserError> {
|
||||
Self::Request::parse(parts)
|
||||
}
|
||||
|
||||
/// Parse the raw request string into a request.
|
||||
/// This assumes the raw string starts with the command name, e.g. `command_name arg1 "arg2 arg3"`
|
||||
fn parse_raw_request(raw: &str) -> Result<Self::Request, RequestParserError> {
|
||||
Self::Request::parse_raw(raw)
|
||||
}
|
||||
|
||||
// /// Serialize the response into a string.
|
||||
// fn serialize_response(&self, response: Self::Response) -> String {
|
||||
|
||||
/// Parse the response from its tokenized parts. See also [`parse_raw_response`].
|
||||
fn parse_response(parts: ResponseAttributes) -> Result<Self::Response, ResponseParserError> {
|
||||
Self::Response::parse(parts)
|
||||
}
|
||||
/// Parse the raw response string into a response.
|
||||
fn parse_raw_response(raw: &[u8]) -> Result<Self::Response, ResponseParserError> {
|
||||
Self::Response::parse_raw(raw)
|
||||
}
|
||||
/// Serializes the response to its raw byte representaion.
|
||||
///
|
||||
/// Note that this does not include the trailing `OK\n` terminator.
|
||||
fn serialize(&self) -> Vec<u8>;
|
||||
}
|
||||
|
||||
// Request/response implementation helpers
|
||||
@@ -196,6 +166,8 @@ macro_rules! empty_command_request {
|
||||
}
|
||||
|
||||
impl crate::commands::CommandRequest for paste::paste! { [<$name Request>] } {
|
||||
type Response = paste::paste! { [<$name Response>] };
|
||||
|
||||
const COMMAND: &'static str = $command_name;
|
||||
const MIN_ARGS: u32 = 0;
|
||||
const MAX_ARGS: Option<u32> = Some(0);
|
||||
@@ -229,12 +201,18 @@ macro_rules! empty_command_response {
|
||||
}
|
||||
|
||||
impl crate::commands::CommandResponse for paste::paste! { [<$name Response>] } {
|
||||
type Request = paste::paste! { [<$name Request>] };
|
||||
|
||||
fn parse(
|
||||
_parts: crate::commands::ResponseAttributes<'_>,
|
||||
) -> Result<Self, crate::commands::ResponseParserError> {
|
||||
debug_assert!(_parts.is_empty());
|
||||
Ok(paste::paste! { [<$name Response>] })
|
||||
}
|
||||
|
||||
fn serialize(&self) -> Vec<u8> {
|
||||
Vec::with_capacity(0)
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -255,6 +233,8 @@ macro_rules! single_item_command_request {
|
||||
}
|
||||
|
||||
impl crate::commands::CommandRequest for paste::paste! { [<$name Request>] } {
|
||||
type Response = paste::paste! { [<$name Response>] };
|
||||
|
||||
const COMMAND: &'static str = $command_name;
|
||||
const MIN_ARGS: u32 = 1;
|
||||
const MAX_ARGS: Option<u32> = Some(1);
|
||||
@@ -300,6 +280,8 @@ macro_rules! single_optional_item_command_request {
|
||||
}
|
||||
|
||||
impl crate::commands::CommandRequest for paste::paste! { [<$name Request>] } {
|
||||
type Response = paste::paste! { [<$name Response>] };
|
||||
|
||||
const COMMAND: &'static str = $command_name;
|
||||
const MIN_ARGS: u32 = 0;
|
||||
const MAX_ARGS: Option<u32> = Some(1);
|
||||
@@ -351,6 +333,8 @@ macro_rules! single_item_command_response {
|
||||
}
|
||||
|
||||
impl crate::commands::CommandResponse for paste::paste! { [<$name Response>] } {
|
||||
type Request = paste::paste! { [<$name Request>] };
|
||||
|
||||
fn parse(
|
||||
parts: crate::commands::ResponseAttributes<'_>,
|
||||
) -> Result<Self, crate::commands::ResponseParserError> {
|
||||
@@ -375,6 +359,15 @@ macro_rules! single_item_command_response {
|
||||
|
||||
Ok(paste::paste! { [<$name Response>] ( item ) })
|
||||
}
|
||||
|
||||
fn serialize(&self) -> Vec<u8> {
|
||||
paste::paste! {
|
||||
unimplemented!(concat!(
|
||||
"response serialization is not yet implemented for ",
|
||||
stringify!([<$name Response>])
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -395,6 +388,8 @@ macro_rules! multi_item_command_response {
|
||||
}
|
||||
|
||||
impl crate::commands::CommandResponse for paste::paste! { [<$name Response>] } {
|
||||
type Request = paste::paste! { [<$name Request>] };
|
||||
|
||||
fn parse(
|
||||
parts: crate::commands::ResponseAttributes<'_>,
|
||||
) -> Result<Self, crate::commands::ResponseParserError> {
|
||||
@@ -422,6 +417,15 @@ macro_rules! multi_item_command_response {
|
||||
|
||||
Ok(paste::paste! { [<$name Response>] ( items ) })
|
||||
}
|
||||
|
||||
fn serialize(&self) -> Vec<u8> {
|
||||
paste::paste! {
|
||||
unimplemented!(concat!(
|
||||
"response serialization is not yet implemented for ",
|
||||
stringify!([<$name Response>])
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -569,147 +573,147 @@ pub enum ResponseParserError {
|
||||
|
||||
pub const COMMAND_NAMES: &[&str] = &[
|
||||
// Audio output devices
|
||||
DisableOutput::COMMAND,
|
||||
EnableOutput::COMMAND,
|
||||
Outputs::COMMAND,
|
||||
OutputSet::COMMAND,
|
||||
ToggleOutput::COMMAND,
|
||||
DisableOutputRequest::COMMAND,
|
||||
EnableOutputRequest::COMMAND,
|
||||
OutputsRequest::COMMAND,
|
||||
OutputSetRequest::COMMAND,
|
||||
ToggleOutputRequest::COMMAND,
|
||||
// Client to client
|
||||
Channels::COMMAND,
|
||||
ReadMessages::COMMAND,
|
||||
SendMessage::COMMAND,
|
||||
Subscribe::COMMAND,
|
||||
Unsubscribe::COMMAND,
|
||||
ChannelsRequest::COMMAND,
|
||||
ReadMessagesRequest::COMMAND,
|
||||
SendMessageRequest::COMMAND,
|
||||
SubscribeRequest::COMMAND,
|
||||
UnsubscribeRequest::COMMAND,
|
||||
// Connection settings
|
||||
BinaryLimit::COMMAND,
|
||||
Close::COMMAND,
|
||||
Kill::COMMAND,
|
||||
Password::COMMAND,
|
||||
Ping::COMMAND,
|
||||
Protocol::COMMAND,
|
||||
ProtocolAll::COMMAND,
|
||||
ProtocolAvailable::COMMAND,
|
||||
ProtocolClear::COMMAND,
|
||||
ProtocolDisable::COMMAND,
|
||||
ProtocolEnable::COMMAND,
|
||||
TagTypes::COMMAND,
|
||||
TagTypesAll::COMMAND,
|
||||
TagTypesAvailable::COMMAND,
|
||||
TagTypesClear::COMMAND,
|
||||
TagTypesDisable::COMMAND,
|
||||
TagTypesEnable::COMMAND,
|
||||
TagTypesReset::COMMAND,
|
||||
BinaryLimitRequest::COMMAND,
|
||||
CloseRequest::COMMAND,
|
||||
KillRequest::COMMAND,
|
||||
PasswordRequest::COMMAND,
|
||||
PingRequest::COMMAND,
|
||||
ProtocolRequest::COMMAND,
|
||||
ProtocolAllRequest::COMMAND,
|
||||
ProtocolAvailableRequest::COMMAND,
|
||||
ProtocolClearRequest::COMMAND,
|
||||
ProtocolDisableRequest::COMMAND,
|
||||
ProtocolEnableRequest::COMMAND,
|
||||
TagTypesRequest::COMMAND,
|
||||
TagTypesAllRequest::COMMAND,
|
||||
TagTypesAvailableRequest::COMMAND,
|
||||
TagTypesClearRequest::COMMAND,
|
||||
TagTypesDisableRequest::COMMAND,
|
||||
TagTypesEnableRequest::COMMAND,
|
||||
TagTypesResetRequest::COMMAND,
|
||||
// Controlling playback
|
||||
Next::COMMAND,
|
||||
Pause::COMMAND,
|
||||
Play::COMMAND,
|
||||
PlayId::COMMAND,
|
||||
Previous::COMMAND,
|
||||
Seek::COMMAND,
|
||||
SeekCur::COMMAND,
|
||||
SeekId::COMMAND,
|
||||
Stop::COMMAND,
|
||||
NextRequest::COMMAND,
|
||||
PauseRequest::COMMAND,
|
||||
PlayRequest::COMMAND,
|
||||
PlayIdRequest::COMMAND,
|
||||
PreviousRequest::COMMAND,
|
||||
SeekRequest::COMMAND,
|
||||
SeekCurRequest::COMMAND,
|
||||
SeekIdRequest::COMMAND,
|
||||
StopRequest::COMMAND,
|
||||
// Mounts and neighbors
|
||||
ListMounts::COMMAND,
|
||||
ListNeighbors::COMMAND,
|
||||
Mount::COMMAND,
|
||||
Unmount::COMMAND,
|
||||
ListMountsRequest::COMMAND,
|
||||
ListNeighborsRequest::COMMAND,
|
||||
MountRequest::COMMAND,
|
||||
UnmountRequest::COMMAND,
|
||||
// Music database
|
||||
AlbumArt::COMMAND,
|
||||
Count::COMMAND,
|
||||
Find::COMMAND,
|
||||
FindAdd::COMMAND,
|
||||
GetFingerprint::COMMAND,
|
||||
List::COMMAND,
|
||||
ListAll::COMMAND,
|
||||
ListAllInfo::COMMAND,
|
||||
ListFiles::COMMAND,
|
||||
LsInfo::COMMAND,
|
||||
ReadComments::COMMAND,
|
||||
ReadPicture::COMMAND,
|
||||
Rescan::COMMAND,
|
||||
Search::COMMAND,
|
||||
SearchAdd::COMMAND,
|
||||
SearchAddPl::COMMAND,
|
||||
SearchCount::COMMAND,
|
||||
Update::COMMAND,
|
||||
AlbumArtRequest::COMMAND,
|
||||
CountRequest::COMMAND,
|
||||
FindRequest::COMMAND,
|
||||
FindAddRequest::COMMAND,
|
||||
GetFingerprintRequest::COMMAND,
|
||||
ListRequest::COMMAND,
|
||||
ListAllRequest::COMMAND,
|
||||
ListAllInfoRequest::COMMAND,
|
||||
ListFilesRequest::COMMAND,
|
||||
LsInfoRequest::COMMAND,
|
||||
ReadCommentsRequest::COMMAND,
|
||||
ReadPictureRequest::COMMAND,
|
||||
RescanRequest::COMMAND,
|
||||
SearchRequest::COMMAND,
|
||||
SearchAddRequest::COMMAND,
|
||||
SearchAddPlRequest::COMMAND,
|
||||
SearchCountRequest::COMMAND,
|
||||
UpdateRequest::COMMAND,
|
||||
// Partition commands
|
||||
DelPartition::COMMAND,
|
||||
ListPartitions::COMMAND,
|
||||
MoveOutput::COMMAND,
|
||||
NewPartition::COMMAND,
|
||||
Partition::COMMAND,
|
||||
DelPartitionRequest::COMMAND,
|
||||
ListPartitionsRequest::COMMAND,
|
||||
MoveOutputRequest::COMMAND,
|
||||
NewPartitionRequest::COMMAND,
|
||||
PartitionRequest::COMMAND,
|
||||
// Playback options
|
||||
Consume::COMMAND,
|
||||
Crossfade::COMMAND,
|
||||
GetVol::COMMAND,
|
||||
MixRampDb::COMMAND,
|
||||
MixRampDelay::COMMAND,
|
||||
Random::COMMAND,
|
||||
Repeat::COMMAND,
|
||||
ReplayGainMode::COMMAND,
|
||||
ReplayGainStatus::COMMAND,
|
||||
SetVol::COMMAND,
|
||||
Single::COMMAND,
|
||||
Volume::COMMAND,
|
||||
ConsumeRequest::COMMAND,
|
||||
CrossfadeRequest::COMMAND,
|
||||
GetVolRequest::COMMAND,
|
||||
MixRampDbRequest::COMMAND,
|
||||
MixRampDelayRequest::COMMAND,
|
||||
RandomRequest::COMMAND,
|
||||
RepeatRequest::COMMAND,
|
||||
ReplayGainModeRequest::COMMAND,
|
||||
ReplayGainStatusRequest::COMMAND,
|
||||
SetVolRequest::COMMAND,
|
||||
SingleRequest::COMMAND,
|
||||
VolumeRequest::COMMAND,
|
||||
// Querying mpd status
|
||||
ClearError::COMMAND,
|
||||
CurrentSong::COMMAND,
|
||||
Idle::COMMAND,
|
||||
Stats::COMMAND,
|
||||
Status::COMMAND,
|
||||
ClearErrorRequest::COMMAND,
|
||||
CurrentSongRequest::COMMAND,
|
||||
IdleRequest::COMMAND,
|
||||
StatsRequest::COMMAND,
|
||||
StatusRequest::COMMAND,
|
||||
// Queue
|
||||
Add::COMMAND,
|
||||
AddId::COMMAND,
|
||||
AddTagId::COMMAND,
|
||||
Clear::COMMAND,
|
||||
ClearTagId::COMMAND,
|
||||
Delete::COMMAND,
|
||||
DeleteId::COMMAND,
|
||||
Move::COMMAND,
|
||||
MoveId::COMMAND,
|
||||
Playlist::COMMAND,
|
||||
PlaylistFind::COMMAND,
|
||||
PlaylistId::COMMAND,
|
||||
PlaylistInfo::COMMAND,
|
||||
PlaylistSearch::COMMAND,
|
||||
PlChanges::COMMAND,
|
||||
PlChangesPosId::COMMAND,
|
||||
Prio::COMMAND,
|
||||
PrioId::COMMAND,
|
||||
RangeId::COMMAND,
|
||||
Shuffle::COMMAND,
|
||||
Swap::COMMAND,
|
||||
SwapId::COMMAND,
|
||||
AddRequest::COMMAND,
|
||||
AddIdRequest::COMMAND,
|
||||
AddTagIdRequest::COMMAND,
|
||||
ClearRequest::COMMAND,
|
||||
ClearTagIdRequest::COMMAND,
|
||||
DeleteRequest::COMMAND,
|
||||
DeleteIdRequest::COMMAND,
|
||||
MoveRequest::COMMAND,
|
||||
MoveIdRequest::COMMAND,
|
||||
PlaylistRequest::COMMAND,
|
||||
PlaylistFindRequest::COMMAND,
|
||||
PlaylistIdRequest::COMMAND,
|
||||
PlaylistInfoRequest::COMMAND,
|
||||
PlaylistSearchRequest::COMMAND,
|
||||
PlChangesRequest::COMMAND,
|
||||
PlChangesPosIdRequest::COMMAND,
|
||||
PrioRequest::COMMAND,
|
||||
PrioIdRequest::COMMAND,
|
||||
RangeIdRequest::COMMAND,
|
||||
ShuffleRequest::COMMAND,
|
||||
SwapRequest::COMMAND,
|
||||
SwapIdRequest::COMMAND,
|
||||
// Reflection
|
||||
Commands::COMMAND,
|
||||
Config::COMMAND,
|
||||
Decoders::COMMAND,
|
||||
NotCommands::COMMAND,
|
||||
UrlHandlers::COMMAND,
|
||||
CommandsRequest::COMMAND,
|
||||
ConfigRequest::COMMAND,
|
||||
DecodersRequest::COMMAND,
|
||||
NotCommandsRequest::COMMAND,
|
||||
UrlHandlersRequest::COMMAND,
|
||||
// Stickers
|
||||
StickerDec::COMMAND,
|
||||
StickerDelete::COMMAND,
|
||||
StickerFind::COMMAND,
|
||||
StickerGet::COMMAND,
|
||||
StickerInc::COMMAND,
|
||||
StickerList::COMMAND,
|
||||
StickerSet::COMMAND,
|
||||
StickerNames::COMMAND,
|
||||
StickerNamesTypes::COMMAND,
|
||||
StickerTypes::COMMAND,
|
||||
StickerDecRequest::COMMAND,
|
||||
StickerDeleteRequest::COMMAND,
|
||||
StickerFindRequest::COMMAND,
|
||||
StickerGetRequest::COMMAND,
|
||||
StickerIncRequest::COMMAND,
|
||||
StickerListRequest::COMMAND,
|
||||
StickerSetRequest::COMMAND,
|
||||
StickerNamesRequest::COMMAND,
|
||||
StickerNamesTypesRequest::COMMAND,
|
||||
StickerTypesRequest::COMMAND,
|
||||
// Stored playlists
|
||||
ListPlaylist::COMMAND,
|
||||
ListPlaylistInfo::COMMAND,
|
||||
ListPlaylists::COMMAND,
|
||||
Load::COMMAND,
|
||||
PlaylistAdd::COMMAND,
|
||||
PlaylistClear::COMMAND,
|
||||
PlaylistDelete::COMMAND,
|
||||
PlaylistLength::COMMAND,
|
||||
PlaylistMove::COMMAND,
|
||||
Rename::COMMAND,
|
||||
Rm::COMMAND,
|
||||
Save::COMMAND,
|
||||
SearchPlaylist::COMMAND,
|
||||
ListPlaylistRequest::COMMAND,
|
||||
ListPlaylistInfoRequest::COMMAND,
|
||||
ListPlaylistsRequest::COMMAND,
|
||||
LoadRequest::COMMAND,
|
||||
PlaylistAddRequest::COMMAND,
|
||||
PlaylistClearRequest::COMMAND,
|
||||
PlaylistDeleteRequest::COMMAND,
|
||||
PlaylistLengthRequest::COMMAND,
|
||||
PlaylistMoveRequest::COMMAND,
|
||||
RenameRequest::COMMAND,
|
||||
RmRequest::COMMAND,
|
||||
SaveRequest::COMMAND,
|
||||
SearchPlaylistRequest::COMMAND,
|
||||
];
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
use crate::{
|
||||
commands::{Command, empty_command_response, single_item_command_request},
|
||||
commands::{empty_command_response, single_item_command_request},
|
||||
types::AudioOutputId,
|
||||
};
|
||||
|
||||
pub struct DisableOutput;
|
||||
|
||||
single_item_command_request!(DisableOutput, "disableoutput", AudioOutputId);
|
||||
|
||||
empty_command_response!(DisableOutput);
|
||||
|
||||
impl Command for DisableOutput {
|
||||
type Request = DisableOutputRequest;
|
||||
type Response = DisableOutputResponse;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
use crate::{
|
||||
commands::{Command, empty_command_response, single_item_command_request},
|
||||
commands::{empty_command_response, single_item_command_request},
|
||||
types::AudioOutputId,
|
||||
};
|
||||
|
||||
pub struct EnableOutput;
|
||||
|
||||
single_item_command_request!(EnableOutput, "enableoutput", AudioOutputId);
|
||||
|
||||
empty_command_response!(EnableOutput);
|
||||
|
||||
impl Command for EnableOutput {
|
||||
type Request = EnableOutputRequest;
|
||||
type Response = EnableOutputResponse;
|
||||
}
|
||||
|
||||
@@ -3,13 +3,11 @@ use std::collections::HashMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandResponse, ResponseParserError, empty_command_request},
|
||||
commands::{CommandResponse, ResponseParserError, empty_command_request},
|
||||
response_tokenizer::{ResponseAttributes, expect_property_type},
|
||||
types::AudioOutputId,
|
||||
};
|
||||
|
||||
pub struct Outputs;
|
||||
|
||||
empty_command_request!(Outputs, "outputs");
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
@@ -49,6 +47,8 @@ impl Output {
|
||||
}
|
||||
|
||||
impl CommandResponse for OutputsResponse {
|
||||
type Request = OutputsRequest;
|
||||
|
||||
fn parse(parts: ResponseAttributes<'_>) -> Result<Self, ResponseParserError> {
|
||||
let parts = parts.into_vec()?;
|
||||
|
||||
@@ -130,11 +130,10 @@ impl CommandResponse for OutputsResponse {
|
||||
|
||||
Ok(OutputsResponse(outputs))
|
||||
}
|
||||
}
|
||||
|
||||
impl Command for Outputs {
|
||||
type Request = OutputsRequest;
|
||||
type Response = OutputsResponse;
|
||||
fn serialize(&self) -> Vec<u8> {
|
||||
unimplemented!("response serialization is not yet implemented for OutputsResponse")
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -157,7 +156,7 @@ mod tests {
|
||||
attribute: fifo_path=/tmp/empidee-visualizer.fifo
|
||||
OK
|
||||
"};
|
||||
let result = Outputs::parse_raw_response(input.as_bytes());
|
||||
let result = OutputsResponse::parse_raw(input.as_bytes());
|
||||
assert_eq!(
|
||||
result,
|
||||
Ok(OutputsResponse(vec![
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandRequest, RequestParserError, empty_command_response},
|
||||
commands::{CommandRequest, RequestParserError, empty_command_response},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
types::AudioOutputId,
|
||||
};
|
||||
|
||||
pub struct OutputSet;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct OutputSetRequest {
|
||||
pub output_id: AudioOutputId,
|
||||
@@ -26,6 +24,8 @@ impl OutputSetRequest {
|
||||
}
|
||||
|
||||
impl CommandRequest for OutputSetRequest {
|
||||
type Response = OutputSetResponse;
|
||||
|
||||
const COMMAND: &'static str = "outputset";
|
||||
const MIN_ARGS: u32 = 3;
|
||||
const MAX_ARGS: Option<u32> = Some(3);
|
||||
@@ -63,8 +63,3 @@ impl CommandRequest for OutputSetRequest {
|
||||
}
|
||||
|
||||
empty_command_response!(OutputSet);
|
||||
|
||||
impl Command for OutputSet {
|
||||
type Request = OutputSetRequest;
|
||||
type Response = OutputSetResponse;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
use crate::{
|
||||
commands::{Command, empty_command_response, single_item_command_request},
|
||||
commands::{empty_command_response, single_item_command_request},
|
||||
types::AudioOutputId,
|
||||
};
|
||||
|
||||
pub struct ToggleOutput;
|
||||
|
||||
single_item_command_request!(ToggleOutput, "toggleoutput", AudioOutputId);
|
||||
|
||||
empty_command_response!(ToggleOutput);
|
||||
|
||||
impl Command for ToggleOutput {
|
||||
type Request = ToggleOutputRequest;
|
||||
type Response = ToggleOutputResponse;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandResponse, ResponseParserError, empty_command_request},
|
||||
commands::{CommandResponse, ResponseParserError, empty_command_request},
|
||||
response_tokenizer::{ResponseAttributes, expect_property_type},
|
||||
types::ChannelName,
|
||||
};
|
||||
|
||||
pub struct Channels;
|
||||
|
||||
empty_command_request!(Channels, "channels");
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
@@ -22,6 +20,8 @@ impl ChannelsResponse {
|
||||
}
|
||||
|
||||
impl CommandResponse for ChannelsResponse {
|
||||
type Request = ChannelsRequest;
|
||||
|
||||
fn parse(parts: ResponseAttributes<'_>) -> Result<Self, ResponseParserError> {
|
||||
let parts: Vec<_> = parts.into_vec()?;
|
||||
let mut channel_names = Vec::with_capacity(parts.len());
|
||||
@@ -38,11 +38,10 @@ impl CommandResponse for ChannelsResponse {
|
||||
channels: channel_names,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl Command for Channels {
|
||||
type Request = ChannelsRequest;
|
||||
type Response = ChannelsResponse;
|
||||
fn serialize(&self) -> Vec<u8> {
|
||||
unimplemented!("response serialization is not yet implemented for ChannelsResponse")
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -59,7 +58,7 @@ mod tests {
|
||||
channels: baz
|
||||
OK
|
||||
"};
|
||||
let response = Channels::parse_raw_response(response.as_bytes()).unwrap();
|
||||
let response = ChannelsResponse::parse_raw(response.as_bytes()).unwrap();
|
||||
assert_eq!(
|
||||
response,
|
||||
ChannelsResponse {
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandResponse, ResponseParserError, empty_command_request},
|
||||
commands::{CommandResponse, ResponseParserError, empty_command_request},
|
||||
response_tokenizer::{ResponseAttributes, expect_property_type},
|
||||
types::ChannelName,
|
||||
};
|
||||
|
||||
pub struct ReadMessages;
|
||||
|
||||
empty_command_request!(ReadMessages, "readmessages");
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
@@ -32,6 +30,8 @@ impl ReadMessagesResponseEntry {
|
||||
}
|
||||
|
||||
impl CommandResponse for ReadMessagesResponse {
|
||||
type Request = ReadMessagesRequest;
|
||||
|
||||
fn parse(parts: ResponseAttributes<'_>) -> Result<Self, ResponseParserError> {
|
||||
let parts: Vec<_> = parts.into_vec()?;
|
||||
debug_assert!(parts.len() % 2 == 0);
|
||||
@@ -57,11 +57,10 @@ impl CommandResponse for ReadMessagesResponse {
|
||||
|
||||
Ok(ReadMessagesResponse(messages))
|
||||
}
|
||||
}
|
||||
|
||||
impl Command for ReadMessages {
|
||||
type Request = ReadMessagesRequest;
|
||||
type Response = ReadMessagesResponse;
|
||||
fn serialize(&self) -> Vec<u8> {
|
||||
unimplemented!("response serialization is not yet implemented for ReadMessagesResponse")
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -79,7 +78,7 @@ mod tests {
|
||||
message: message2
|
||||
OK
|
||||
"};
|
||||
let result = ReadMessages::parse_raw_response(input.as_bytes());
|
||||
let result = ReadMessagesResponse::parse_raw(input.as_bytes());
|
||||
assert_eq!(
|
||||
result,
|
||||
Ok(ReadMessagesResponse(vec![
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandRequest, RequestParserError, empty_command_response},
|
||||
commands::{CommandRequest, RequestParserError, empty_command_response},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
types::ChannelName,
|
||||
};
|
||||
|
||||
pub struct SendMessage;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct SendMessageRequest {
|
||||
pub channel: ChannelName,
|
||||
@@ -21,6 +19,8 @@ impl SendMessageRequest {
|
||||
}
|
||||
|
||||
impl CommandRequest for SendMessageRequest {
|
||||
type Response = SendMessageResponse;
|
||||
|
||||
const COMMAND: &'static str = "sendmessage";
|
||||
const MIN_ARGS: u32 = 2;
|
||||
const MAX_ARGS: Option<u32> = None;
|
||||
@@ -47,8 +47,3 @@ impl CommandRequest for SendMessageRequest {
|
||||
}
|
||||
|
||||
empty_command_response!(SendMessage);
|
||||
|
||||
impl Command for SendMessage {
|
||||
type Request = SendMessageRequest;
|
||||
type Response = SendMessageResponse;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
use crate::{
|
||||
commands::{Command, empty_command_response, single_item_command_request},
|
||||
commands::{empty_command_response, single_item_command_request},
|
||||
types::ChannelName,
|
||||
};
|
||||
|
||||
pub struct Subscribe;
|
||||
|
||||
single_item_command_request!(Subscribe, "subscribe", ChannelName);
|
||||
|
||||
empty_command_response!(Subscribe);
|
||||
|
||||
impl Command for Subscribe {
|
||||
type Request = SubscribeRequest;
|
||||
type Response = SubscribeResponse;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
use crate::{
|
||||
commands::{Command, empty_command_response, single_item_command_request},
|
||||
commands::{empty_command_response, single_item_command_request},
|
||||
types::ChannelName,
|
||||
};
|
||||
|
||||
pub struct Unsubscribe;
|
||||
|
||||
single_item_command_request!(Unsubscribe, "unsubscribe", ChannelName);
|
||||
|
||||
empty_command_response!(Unsubscribe);
|
||||
|
||||
impl Command for Unsubscribe {
|
||||
type Request = UnsubscribeRequest;
|
||||
type Response = UnsubscribeResponse;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
use crate::commands::{Command, empty_command_response, single_item_command_request};
|
||||
|
||||
pub struct BinaryLimit;
|
||||
use crate::commands::{empty_command_response, single_item_command_request};
|
||||
|
||||
single_item_command_request!(BinaryLimit, "binarylimit", u64);
|
||||
|
||||
empty_command_response!(BinaryLimit);
|
||||
|
||||
impl Command for BinaryLimit {
|
||||
type Request = BinaryLimitRequest;
|
||||
type Response = BinaryLimitResponse;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
use crate::commands::{Command, empty_command_request, empty_command_response};
|
||||
|
||||
pub struct Close;
|
||||
use crate::commands::{empty_command_request, empty_command_response};
|
||||
|
||||
empty_command_request!(Close, "close");
|
||||
|
||||
empty_command_response!(Close);
|
||||
|
||||
impl Command for Close {
|
||||
type Request = CloseRequest;
|
||||
type Response = CloseResponse;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
use crate::commands::{Command, empty_command_request, empty_command_response};
|
||||
|
||||
pub struct Kill;
|
||||
use crate::commands::{empty_command_request, empty_command_response};
|
||||
|
||||
empty_command_request!(Kill, "kill");
|
||||
|
||||
empty_command_response!(Kill);
|
||||
|
||||
impl Command for Kill {
|
||||
type Request = KillRequest;
|
||||
type Response = KillResponse;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
use crate::commands::{Command, empty_command_response, single_item_command_request};
|
||||
|
||||
pub struct Password;
|
||||
use crate::commands::{empty_command_response, single_item_command_request};
|
||||
|
||||
single_item_command_request!(Password, "password", String);
|
||||
|
||||
empty_command_response!(Password);
|
||||
|
||||
impl Command for Password {
|
||||
type Request = PasswordRequest;
|
||||
type Response = PasswordResponse;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
use crate::commands::{Command, empty_command_request, empty_command_response};
|
||||
|
||||
pub struct Ping;
|
||||
use crate::commands::{empty_command_request, empty_command_response};
|
||||
|
||||
empty_command_request!(Ping, "ping");
|
||||
|
||||
empty_command_response!(Ping);
|
||||
|
||||
impl Command for Ping {
|
||||
type Request = PingRequest;
|
||||
type Response = PingResponse;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
use crate::{
|
||||
commands::{Command, ResponseParserError, empty_command_request, multi_item_command_response},
|
||||
commands::{ResponseParserError, empty_command_request, multi_item_command_response},
|
||||
response_tokenizer::expect_property_type,
|
||||
};
|
||||
|
||||
pub struct Protocol;
|
||||
|
||||
empty_command_request!(Protocol, "protocol");
|
||||
|
||||
multi_item_command_response!(Protocol, "feature", String);
|
||||
|
||||
impl Command for Protocol {
|
||||
type Request = ProtocolRequest;
|
||||
type Response = ProtocolResponse;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
use crate::commands::{Command, empty_command_request, empty_command_response};
|
||||
|
||||
pub struct ProtocolAll;
|
||||
use crate::commands::{empty_command_request, empty_command_response};
|
||||
|
||||
empty_command_request!(ProtocolAll, "protocol all");
|
||||
|
||||
empty_command_response!(ProtocolAll);
|
||||
|
||||
impl Command for ProtocolAll {
|
||||
type Request = ProtocolAllRequest;
|
||||
type Response = ProtocolAllResponse;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
use crate::{
|
||||
commands::{Command, ResponseParserError, empty_command_request, multi_item_command_response},
|
||||
commands::{ResponseParserError, empty_command_request, multi_item_command_response},
|
||||
response_tokenizer::expect_property_type,
|
||||
};
|
||||
|
||||
pub struct ProtocolAvailable;
|
||||
|
||||
empty_command_request!(ProtocolAvailable, "protocol available");
|
||||
|
||||
multi_item_command_response!(ProtocolAvailable, "feature", String);
|
||||
|
||||
impl Command for ProtocolAvailable {
|
||||
type Request = ProtocolAvailableRequest;
|
||||
type Response = ProtocolAvailableResponse;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
use crate::commands::{Command, empty_command_request, empty_command_response};
|
||||
|
||||
pub struct ProtocolClear;
|
||||
use crate::commands::{empty_command_request, empty_command_response};
|
||||
|
||||
empty_command_request!(ProtocolClear, "protocol clear");
|
||||
|
||||
empty_command_response!(ProtocolClear);
|
||||
|
||||
impl Command for ProtocolClear {
|
||||
type Request = ProtocolClearRequest;
|
||||
type Response = ProtocolClearResponse;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
use crate::{
|
||||
commands::{Command, CommandRequest, RequestParserError, empty_command_response},
|
||||
commands::{CommandRequest, RequestParserError, empty_command_response},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
types::Feature,
|
||||
};
|
||||
|
||||
pub struct ProtocolDisable;
|
||||
|
||||
pub struct ProtocolDisableRequest(Vec<Feature>);
|
||||
|
||||
impl ProtocolDisableRequest {
|
||||
@@ -15,6 +13,8 @@ impl ProtocolDisableRequest {
|
||||
}
|
||||
|
||||
impl CommandRequest for ProtocolDisableRequest {
|
||||
type Response = ProtocolDisableResponse;
|
||||
|
||||
const COMMAND: &'static str = "protocol disable";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
const MAX_ARGS: Option<u32> = None;
|
||||
@@ -52,8 +52,3 @@ impl CommandRequest for ProtocolDisableRequest {
|
||||
}
|
||||
|
||||
empty_command_response!(ProtocolDisable);
|
||||
|
||||
impl Command for ProtocolDisable {
|
||||
type Request = ProtocolDisableRequest;
|
||||
type Response = ProtocolDisableResponse;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
use crate::{
|
||||
commands::{Command, CommandRequest, RequestParserError, empty_command_response},
|
||||
commands::{CommandRequest, RequestParserError, empty_command_response},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
types::Feature,
|
||||
};
|
||||
|
||||
pub struct ProtocolEnable;
|
||||
|
||||
pub struct ProtocolEnableRequest(Vec<Feature>);
|
||||
|
||||
impl ProtocolEnableRequest {
|
||||
@@ -15,6 +13,8 @@ impl ProtocolEnableRequest {
|
||||
}
|
||||
|
||||
impl CommandRequest for ProtocolEnableRequest {
|
||||
type Response = ProtocolEnableResponse;
|
||||
|
||||
const COMMAND: &'static str = "protocol enable";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
const MAX_ARGS: Option<u32> = None;
|
||||
@@ -52,8 +52,3 @@ impl CommandRequest for ProtocolEnableRequest {
|
||||
}
|
||||
|
||||
empty_command_response!(ProtocolEnable);
|
||||
|
||||
impl Command for ProtocolEnable {
|
||||
type Request = ProtocolEnableRequest;
|
||||
type Response = ProtocolEnableResponse;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
use crate::{
|
||||
commands::{Command, ResponseParserError, empty_command_request, multi_item_command_response},
|
||||
commands::{ResponseParserError, empty_command_request, multi_item_command_response},
|
||||
response_tokenizer::expect_property_type,
|
||||
};
|
||||
|
||||
pub struct TagTypes;
|
||||
|
||||
empty_command_request!(TagTypes, "tagtypes");
|
||||
|
||||
multi_item_command_response!(TagTypes, "tagtype", String);
|
||||
|
||||
impl Command for TagTypes {
|
||||
type Request = TagTypesRequest;
|
||||
type Response = TagTypesResponse;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
use crate::commands::{Command, empty_command_request, empty_command_response};
|
||||
|
||||
pub struct TagTypesAll;
|
||||
use crate::commands::{empty_command_request, empty_command_response};
|
||||
|
||||
empty_command_request!(TagTypesAll, "tagtypes all");
|
||||
|
||||
empty_command_response!(TagTypesAll);
|
||||
|
||||
impl Command for TagTypesAll {
|
||||
type Request = TagTypesAllRequest;
|
||||
type Response = TagTypesAllResponse;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
use crate::{
|
||||
commands::{Command, ResponseParserError, empty_command_request, multi_item_command_response},
|
||||
commands::{ResponseParserError, empty_command_request, multi_item_command_response},
|
||||
response_tokenizer::expect_property_type,
|
||||
};
|
||||
|
||||
pub struct TagTypesAvailable;
|
||||
|
||||
empty_command_request!(TagTypesAvailable, "tagtypes available");
|
||||
|
||||
multi_item_command_response!(TagTypesAvailable, "tagtype", String);
|
||||
|
||||
impl Command for TagTypesAvailable {
|
||||
type Request = TagTypesAvailableRequest;
|
||||
type Response = TagTypesAvailableResponse;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
use crate::commands::{Command, empty_command_request, empty_command_response};
|
||||
|
||||
pub struct TagTypesClear;
|
||||
use crate::commands::{empty_command_request, empty_command_response};
|
||||
|
||||
empty_command_request!(TagTypesClear, "tagtypes clear");
|
||||
|
||||
empty_command_response!(TagTypesClear);
|
||||
|
||||
impl Command for TagTypesClear {
|
||||
type Request = TagTypesClearRequest;
|
||||
type Response = TagTypesClearResponse;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
use crate::{
|
||||
commands::{Command, CommandRequest, RequestParserError, empty_command_response},
|
||||
commands::{CommandRequest, RequestParserError, empty_command_response},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
types::TagName,
|
||||
};
|
||||
|
||||
pub struct TagTypesDisable;
|
||||
|
||||
pub struct TagTypesDisableRequest(Vec<TagName>);
|
||||
|
||||
impl TagTypesDisableRequest {
|
||||
@@ -15,6 +13,8 @@ impl TagTypesDisableRequest {
|
||||
}
|
||||
|
||||
impl CommandRequest for TagTypesDisableRequest {
|
||||
type Response = TagTypesDisableResponse;
|
||||
|
||||
const COMMAND: &'static str = "tagtypes disable";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
const MAX_ARGS: Option<u32> = None;
|
||||
@@ -54,8 +54,3 @@ impl CommandRequest for TagTypesDisableRequest {
|
||||
}
|
||||
|
||||
empty_command_response!(TagTypesDisable);
|
||||
|
||||
impl Command for TagTypesDisable {
|
||||
type Request = TagTypesDisableRequest;
|
||||
type Response = TagTypesDisableResponse;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
use crate::{
|
||||
commands::{Command, CommandRequest, RequestParserError, empty_command_response},
|
||||
commands::{CommandRequest, RequestParserError, empty_command_response},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
types::TagName,
|
||||
};
|
||||
|
||||
pub struct TagTypesEnable;
|
||||
|
||||
pub struct TagTypesEnableRequest(Vec<TagName>);
|
||||
|
||||
impl TagTypesEnableRequest {
|
||||
@@ -15,6 +13,8 @@ impl TagTypesEnableRequest {
|
||||
}
|
||||
|
||||
impl CommandRequest for TagTypesEnableRequest {
|
||||
type Response = TagTypesEnableResponse;
|
||||
|
||||
const COMMAND: &'static str = "tagtypes enable";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
const MAX_ARGS: Option<u32> = None;
|
||||
@@ -54,8 +54,3 @@ impl CommandRequest for TagTypesEnableRequest {
|
||||
}
|
||||
|
||||
empty_command_response!(TagTypesEnable);
|
||||
|
||||
impl Command for TagTypesEnable {
|
||||
type Request = TagTypesEnableRequest;
|
||||
type Response = TagTypesEnableResponse;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
use crate::{
|
||||
commands::{Command, CommandRequest, RequestParserError, empty_command_response},
|
||||
commands::{CommandRequest, RequestParserError, empty_command_response},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
types::TagName,
|
||||
};
|
||||
|
||||
pub struct TagTypesReset;
|
||||
|
||||
pub struct TagTypesResetRequest(Vec<TagName>);
|
||||
|
||||
impl TagTypesResetRequest {
|
||||
@@ -15,6 +13,8 @@ impl TagTypesResetRequest {
|
||||
}
|
||||
|
||||
impl CommandRequest for TagTypesResetRequest {
|
||||
type Response = TagTypesResetResponse;
|
||||
|
||||
const COMMAND: &'static str = "tagtypes reset";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
const MAX_ARGS: Option<u32> = None;
|
||||
@@ -54,8 +54,3 @@ impl CommandRequest for TagTypesResetRequest {
|
||||
}
|
||||
|
||||
empty_command_response!(TagTypesReset);
|
||||
|
||||
impl Command for TagTypesReset {
|
||||
type Request = TagTypesResetRequest;
|
||||
type Response = TagTypesResetResponse;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
use crate::commands::{Command, empty_command_request, empty_command_response};
|
||||
|
||||
pub struct Next;
|
||||
use crate::commands::{empty_command_request, empty_command_response};
|
||||
|
||||
empty_command_request!(Next, "next");
|
||||
|
||||
empty_command_response!(Next);
|
||||
|
||||
impl Command for Next {
|
||||
type Request = NextRequest;
|
||||
type Response = NextResponse;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
use crate::{
|
||||
commands::{Command, CommandRequest, RequestParserError, empty_command_response},
|
||||
commands::{CommandRequest, RequestParserError, empty_command_response},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
};
|
||||
|
||||
pub struct Pause;
|
||||
|
||||
pub struct PauseRequest(Option<bool>);
|
||||
|
||||
impl PauseRequest {
|
||||
@@ -14,6 +12,8 @@ impl PauseRequest {
|
||||
}
|
||||
|
||||
impl CommandRequest for PauseRequest {
|
||||
type Response = PauseResponse;
|
||||
|
||||
const COMMAND: &'static str = "pause";
|
||||
const MIN_ARGS: u32 = 0;
|
||||
const MAX_ARGS: Option<u32> = Some(1);
|
||||
@@ -45,8 +45,3 @@ impl CommandRequest for PauseRequest {
|
||||
}
|
||||
|
||||
empty_command_response!(Pause);
|
||||
|
||||
impl Command for Pause {
|
||||
type Request = PauseRequest;
|
||||
type Response = PauseResponse;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
use crate::{
|
||||
commands::{Command, empty_command_response, single_optional_item_command_request},
|
||||
commands::{empty_command_response, single_optional_item_command_request},
|
||||
types::SongPosition,
|
||||
};
|
||||
|
||||
pub struct Play;
|
||||
|
||||
single_optional_item_command_request!(Play, "play", SongPosition);
|
||||
|
||||
empty_command_response!(Play);
|
||||
|
||||
impl Command for Play {
|
||||
type Request = PlayRequest;
|
||||
type Response = PlayResponse;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
use crate::{
|
||||
commands::{Command, empty_command_response, single_optional_item_command_request},
|
||||
commands::{empty_command_response, single_optional_item_command_request},
|
||||
types::SongId,
|
||||
};
|
||||
|
||||
pub struct PlayId;
|
||||
|
||||
single_optional_item_command_request!(PlayId, "playid", SongId);
|
||||
|
||||
empty_command_response!(PlayId);
|
||||
|
||||
impl Command for PlayId {
|
||||
type Request = PlayIdRequest;
|
||||
type Response = PlayIdResponse;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
use crate::commands::{Command, empty_command_request, empty_command_response};
|
||||
|
||||
pub struct Previous;
|
||||
use crate::commands::{empty_command_request, empty_command_response};
|
||||
|
||||
empty_command_request!(Previous, "previous");
|
||||
|
||||
empty_command_response!(Previous);
|
||||
|
||||
impl Command for Previous {
|
||||
type Request = PreviousRequest;
|
||||
type Response = PreviousResponse;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandRequest, RequestParserError, empty_command_response},
|
||||
commands::{CommandRequest, RequestParserError, empty_command_response},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
types::{SongPosition, TimeWithFractions},
|
||||
};
|
||||
|
||||
pub struct Seek;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct SeekRequest {
|
||||
pub songpos: SongPosition,
|
||||
@@ -21,6 +19,8 @@ impl SeekRequest {
|
||||
}
|
||||
|
||||
impl CommandRequest for SeekRequest {
|
||||
type Response = SeekResponse;
|
||||
|
||||
const COMMAND: &'static str = "seek";
|
||||
const MIN_ARGS: u32 = 2;
|
||||
const MAX_ARGS: Option<u32> = Some(2);
|
||||
@@ -61,8 +61,3 @@ impl CommandRequest for SeekRequest {
|
||||
}
|
||||
|
||||
empty_command_response!(Seek);
|
||||
|
||||
impl Command for Seek {
|
||||
type Request = SeekRequest;
|
||||
type Response = SeekResponse;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandRequest, RequestParserError, empty_command_response},
|
||||
commands::{CommandRequest, RequestParserError, empty_command_response},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
types::{SeekMode, TimeWithFractions},
|
||||
};
|
||||
|
||||
pub struct SeekCur;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct SeekCurRequest {
|
||||
pub mode: SeekMode,
|
||||
@@ -21,6 +19,8 @@ impl SeekCurRequest {
|
||||
}
|
||||
|
||||
impl CommandRequest for SeekCurRequest {
|
||||
type Response = SeekCurResponse;
|
||||
|
||||
const COMMAND: &'static str = "seekcur";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
const MAX_ARGS: Option<u32> = Some(1);
|
||||
@@ -84,8 +84,3 @@ impl CommandRequest for SeekCurRequest {
|
||||
}
|
||||
|
||||
empty_command_response!(SeekCur);
|
||||
|
||||
impl Command for SeekCur {
|
||||
type Request = SeekCurRequest;
|
||||
type Response = SeekCurResponse;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandRequest, RequestParserError, empty_command_response},
|
||||
commands::{CommandRequest, RequestParserError, empty_command_response},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
types::{SongId, TimeWithFractions},
|
||||
};
|
||||
|
||||
pub struct SeekId;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct SeekIdRequest {
|
||||
pub songid: SongId,
|
||||
@@ -21,6 +19,8 @@ impl SeekIdRequest {
|
||||
}
|
||||
|
||||
impl CommandRequest for SeekIdRequest {
|
||||
type Response = SeekIdResponse;
|
||||
|
||||
const COMMAND: &'static str = "seekid";
|
||||
const MIN_ARGS: u32 = 2;
|
||||
const MAX_ARGS: Option<u32> = Some(2);
|
||||
@@ -59,8 +59,3 @@ impl CommandRequest for SeekIdRequest {
|
||||
}
|
||||
|
||||
empty_command_response!(SeekId);
|
||||
|
||||
impl Command for SeekId {
|
||||
type Request = SeekIdRequest;
|
||||
type Response = SeekIdResponse;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
use crate::commands::{Command, empty_command_request, empty_command_response};
|
||||
|
||||
pub struct Stop;
|
||||
use crate::commands::{empty_command_request, empty_command_response};
|
||||
|
||||
empty_command_request!(Stop, "stop");
|
||||
|
||||
empty_command_response!(Stop);
|
||||
|
||||
impl Command for Stop {
|
||||
type Request = StopRequest;
|
||||
type Response = StopResponse;
|
||||
}
|
||||
|
||||
@@ -1,24 +1,18 @@
|
||||
use crate::{
|
||||
commands::{Command, ResponseParserError, empty_command_request, multi_item_command_response},
|
||||
commands::{ResponseParserError, empty_command_request, multi_item_command_response},
|
||||
response_tokenizer::expect_property_type,
|
||||
};
|
||||
|
||||
pub struct ListMounts;
|
||||
|
||||
empty_command_request!(ListMounts, "listmounts");
|
||||
|
||||
multi_item_command_response!(ListMounts, "mount", String);
|
||||
|
||||
impl Command for ListMounts {
|
||||
type Request = ListMountsRequest;
|
||||
type Response = ListMountsResponse;
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use indoc::indoc;
|
||||
|
||||
use super::*;
|
||||
use crate::commands::CommandResponse;
|
||||
|
||||
#[test]
|
||||
fn test_parse_response() {
|
||||
@@ -27,7 +21,7 @@ mod tests {
|
||||
mount: /mnt/music
|
||||
OK
|
||||
"};
|
||||
let result = ListMounts::parse_raw_response(input.as_bytes());
|
||||
let result = ListMountsResponse::parse_raw(input.as_bytes());
|
||||
assert_eq!(
|
||||
result,
|
||||
Ok(ListMountsResponse(vec![
|
||||
|
||||
@@ -3,12 +3,10 @@ use std::collections::HashMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandResponse, ResponseParserError, empty_command_request},
|
||||
commands::{CommandResponse, ResponseParserError, empty_command_request},
|
||||
response_tokenizer::{ResponseAttributes, expect_property_type},
|
||||
};
|
||||
|
||||
pub struct ListNeighbors;
|
||||
|
||||
empty_command_request!(ListNeighbors, "listneighbors");
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
@@ -21,6 +19,8 @@ impl ListNeighborsResponse {
|
||||
}
|
||||
|
||||
impl CommandResponse for ListNeighborsResponse {
|
||||
type Request = ListNeighborsRequest;
|
||||
|
||||
fn parse(parts: ResponseAttributes<'_>) -> Result<Self, ResponseParserError> {
|
||||
let parts: Vec<_> = parts.into_vec()?;
|
||||
debug_assert!(parts.len() % 2 == 0);
|
||||
@@ -42,9 +42,8 @@ impl CommandResponse for ListNeighborsResponse {
|
||||
|
||||
Ok(ListNeighborsResponse(result))
|
||||
}
|
||||
}
|
||||
|
||||
impl Command for ListNeighbors {
|
||||
type Request = ListNeighborsRequest;
|
||||
type Response = ListNeighborsResponse;
|
||||
fn serialize(&self) -> Vec<u8> {
|
||||
unimplemented!("response serialization is not yet implemented for ListNeighborsResponse")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandRequest, RequestParserError, empty_command_response},
|
||||
commands::{CommandRequest, RequestParserError, empty_command_response},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
types::{MountPath, Uri},
|
||||
};
|
||||
|
||||
pub struct Mount;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct MountRequest {
|
||||
pub path: MountPath,
|
||||
@@ -21,6 +19,8 @@ impl MountRequest {
|
||||
}
|
||||
|
||||
impl CommandRequest for MountRequest {
|
||||
type Response = MountResponse;
|
||||
|
||||
const COMMAND: &'static str = "mount";
|
||||
const MIN_ARGS: u32 = 2;
|
||||
const MAX_ARGS: Option<u32> = Some(2);
|
||||
@@ -57,8 +57,3 @@ impl CommandRequest for MountRequest {
|
||||
}
|
||||
|
||||
empty_command_response!(Mount);
|
||||
|
||||
impl Command for Mount {
|
||||
type Request = MountRequest;
|
||||
type Response = MountResponse;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
use crate::{
|
||||
commands::{
|
||||
Command, CommandRequest, RequestParserError, RequestTokenizer, empty_command_response,
|
||||
},
|
||||
commands::{CommandRequest, RequestParserError, RequestTokenizer, empty_command_response},
|
||||
types::MountPath,
|
||||
};
|
||||
|
||||
pub struct Unmount;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
pub struct UnmountRequest(MountPath);
|
||||
|
||||
@@ -17,6 +13,8 @@ impl UnmountRequest {
|
||||
}
|
||||
|
||||
impl CommandRequest for UnmountRequest {
|
||||
type Response = UnmountResponse;
|
||||
|
||||
const COMMAND: &'static str = "unmount";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
const MAX_ARGS: Option<u32> = Some(1);
|
||||
@@ -47,8 +45,3 @@ impl CommandRequest for UnmountRequest {
|
||||
}
|
||||
|
||||
empty_command_response!(Unmount);
|
||||
|
||||
impl Command for Unmount {
|
||||
type Request = UnmountRequest;
|
||||
type Response = UnmountResponse;
|
||||
}
|
||||
|
||||
@@ -3,14 +3,12 @@ use std::collections::HashMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandRequest, CommandResponse, RequestParserError, ResponseParserError},
|
||||
commands::{CommandRequest, CommandResponse, RequestParserError, ResponseParserError},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::{ResponseAttributes, get_and_parse_property, get_property},
|
||||
types::{Offset, Uri},
|
||||
};
|
||||
|
||||
pub struct AlbumArt;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct AlbumArtRequest {
|
||||
uri: Uri,
|
||||
@@ -24,6 +22,8 @@ impl AlbumArtRequest {
|
||||
}
|
||||
|
||||
impl CommandRequest for AlbumArtRequest {
|
||||
type Response = AlbumArtResponse;
|
||||
|
||||
const COMMAND: &'static str = "albumart";
|
||||
const MIN_ARGS: u32 = 2;
|
||||
const MAX_ARGS: Option<u32> = Some(2);
|
||||
@@ -71,6 +71,8 @@ impl AlbumArtResponse {
|
||||
}
|
||||
|
||||
impl CommandResponse for AlbumArtResponse {
|
||||
type Request = AlbumArtRequest;
|
||||
|
||||
fn parse(parts: ResponseAttributes<'_>) -> Result<Self, ResponseParserError> {
|
||||
let parts: HashMap<_, _> = parts.into_map()?;
|
||||
|
||||
@@ -80,9 +82,8 @@ impl CommandResponse for AlbumArtResponse {
|
||||
|
||||
Ok(AlbumArtResponse { size, binary })
|
||||
}
|
||||
}
|
||||
|
||||
impl Command for AlbumArt {
|
||||
type Request = AlbumArtRequest;
|
||||
type Response = AlbumArtResponse;
|
||||
fn serialize(&self) -> Vec<u8> {
|
||||
unimplemented!("response serialization is not yet implemented for AlbumArtResponse")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,15 +3,13 @@ use std::collections::HashMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandRequest, CommandResponse, RequestParserError, ResponseParserError},
|
||||
commands::{CommandRequest, CommandResponse, RequestParserError, ResponseParserError},
|
||||
filter::Filter,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::{ResponseAttributes, get_and_parse_property},
|
||||
types::GroupType,
|
||||
};
|
||||
|
||||
pub struct Count;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct CountRequest {
|
||||
filter: Filter,
|
||||
@@ -25,6 +23,8 @@ impl CountRequest {
|
||||
}
|
||||
|
||||
impl CommandRequest for CountRequest {
|
||||
type Response = CountResponse;
|
||||
|
||||
const COMMAND: &'static str = "count";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
const MAX_ARGS: Option<u32> = Some(2);
|
||||
@@ -86,6 +86,8 @@ impl CountResponse {
|
||||
}
|
||||
|
||||
impl CommandResponse for CountResponse {
|
||||
type Request = CountRequest;
|
||||
|
||||
fn parse(parts: ResponseAttributes<'_>) -> Result<Self, ResponseParserError> {
|
||||
let parts: HashMap<_, _> = parts.into_map()?;
|
||||
|
||||
@@ -94,9 +96,8 @@ impl CommandResponse for CountResponse {
|
||||
|
||||
Ok(CountResponse { songs, playtime })
|
||||
}
|
||||
}
|
||||
|
||||
impl Command for Count {
|
||||
type Request = CountRequest;
|
||||
type Response = CountResponse;
|
||||
fn serialize(&self) -> Vec<u8> {
|
||||
unimplemented!("response serialization is not yet implemented for CountResponse")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandRequest, CommandResponse, RequestParserError, ResponseParserError},
|
||||
commands::{CommandRequest, CommandResponse, RequestParserError, ResponseParserError},
|
||||
filter::Filter,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
types::{DbSelectionPrintResponse, DbSongInfo, Sort, WindowRange},
|
||||
};
|
||||
|
||||
pub struct Find;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct FindRequest {
|
||||
filter: Filter,
|
||||
@@ -28,6 +26,8 @@ impl FindRequest {
|
||||
}
|
||||
|
||||
impl CommandRequest for FindRequest {
|
||||
type Response = FindResponse;
|
||||
|
||||
const COMMAND: &'static str = "find";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
const MAX_ARGS: Option<u32> = Some(3);
|
||||
@@ -113,6 +113,8 @@ impl FindResponse {
|
||||
}
|
||||
|
||||
impl CommandResponse for FindResponse {
|
||||
type Request = FindRequest;
|
||||
|
||||
fn parse(parts: ResponseAttributes<'_>) -> Result<Self, ResponseParserError> {
|
||||
DbSelectionPrintResponse::parse(parts)?
|
||||
.into_iter()
|
||||
@@ -128,9 +130,8 @@ impl CommandResponse for FindResponse {
|
||||
.collect::<Result<Vec<DbSongInfo>, ResponseParserError>>()
|
||||
.map(FindResponse)
|
||||
}
|
||||
}
|
||||
|
||||
impl Command for Find {
|
||||
type Request = FindRequest;
|
||||
type Response = FindResponse;
|
||||
fn serialize(&self) -> Vec<u8> {
|
||||
unimplemented!("response serialization is not yet implemented for FindResponse")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandRequest, RequestParserError, empty_command_response},
|
||||
commands::{CommandRequest, RequestParserError, empty_command_response},
|
||||
filter::Filter,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
types::{SongPosition, Sort, WindowRange},
|
||||
};
|
||||
|
||||
pub struct FindAdd;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct FindAddRequest {
|
||||
filter: Filter,
|
||||
@@ -34,6 +32,8 @@ impl FindAddRequest {
|
||||
}
|
||||
|
||||
impl CommandRequest for FindAddRequest {
|
||||
type Response = FindAddResponse;
|
||||
|
||||
const COMMAND: &'static str = "findadd";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
const MAX_ARGS: Option<u32> = Some(4);
|
||||
@@ -134,8 +134,3 @@ impl CommandRequest for FindAddRequest {
|
||||
}
|
||||
|
||||
empty_command_response!(FindAdd);
|
||||
|
||||
impl Command for FindAdd {
|
||||
type Request = FindAddRequest;
|
||||
type Response = FindAddResponse;
|
||||
}
|
||||
|
||||
@@ -3,13 +3,11 @@ use std::collections::HashMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandResponse, ResponseParserError, single_item_command_request},
|
||||
commands::{CommandResponse, ResponseParserError, single_item_command_request},
|
||||
response_tokenizer::{ResponseAttributes, get_and_parse_property},
|
||||
types::Uri,
|
||||
};
|
||||
|
||||
pub struct GetFingerprint;
|
||||
|
||||
single_item_command_request!(GetFingerprint, "getfingerprint", Uri);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
@@ -24,6 +22,8 @@ impl GetFingerprintResponse {
|
||||
}
|
||||
|
||||
impl CommandResponse for GetFingerprintResponse {
|
||||
type Request = GetFingerprintRequest;
|
||||
|
||||
fn parse(parts: ResponseAttributes<'_>) -> Result<Self, ResponseParserError> {
|
||||
let parts: HashMap<_, _> = parts.into_map()?;
|
||||
|
||||
@@ -31,9 +31,8 @@ impl CommandResponse for GetFingerprintResponse {
|
||||
|
||||
Ok(GetFingerprintResponse { chromaprint })
|
||||
}
|
||||
}
|
||||
|
||||
impl Command for GetFingerprint {
|
||||
type Request = GetFingerprintRequest;
|
||||
type Response = GetFingerprintResponse;
|
||||
fn serialize(&self) -> Vec<u8> {
|
||||
unimplemented!("response serialization is not yet implemented for GetFingerprintResponse")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandRequest, CommandResponse, RequestParserError, ResponseParserError},
|
||||
commands::{CommandRequest, CommandResponse, RequestParserError, ResponseParserError},
|
||||
filter::Filter,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::{ResponseAttributes, expect_property_type},
|
||||
types::{GroupType, TagName, WindowRange},
|
||||
};
|
||||
|
||||
pub struct List;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct ListRequest {
|
||||
tagname: TagName,
|
||||
@@ -35,6 +33,8 @@ impl ListRequest {
|
||||
}
|
||||
|
||||
impl CommandRequest for ListRequest {
|
||||
type Response = ListResponse;
|
||||
|
||||
const COMMAND: &'static str = "list";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
const MAX_ARGS: Option<u32> = None;
|
||||
@@ -145,6 +145,8 @@ impl ListResponse {
|
||||
}
|
||||
|
||||
impl CommandResponse for ListResponse {
|
||||
type Request = ListRequest;
|
||||
|
||||
fn parse(parts: ResponseAttributes<'_>) -> Result<Self, ResponseParserError> {
|
||||
let parts_: Vec<_> = parts.into_vec()?;
|
||||
debug_assert!({
|
||||
@@ -159,9 +161,8 @@ impl CommandResponse for ListResponse {
|
||||
|
||||
Ok(ListResponse(list))
|
||||
}
|
||||
}
|
||||
|
||||
impl Command for List {
|
||||
type Request = ListRequest;
|
||||
type Response = ListResponse;
|
||||
fn serialize(&self) -> Vec<u8> {
|
||||
unimplemented!("response serialization is not yet implemented for ListResponse")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{
|
||||
Command, CommandResponse, ResponseParserError, single_optional_item_command_request,
|
||||
},
|
||||
commands::{CommandResponse, ResponseParserError, single_optional_item_command_request},
|
||||
response_tokenizer::ResponseAttributes,
|
||||
types::{DbSelectionPrintResponse, Uri},
|
||||
};
|
||||
|
||||
pub struct ListAll;
|
||||
|
||||
single_optional_item_command_request!(ListAll, "listall", Uri);
|
||||
|
||||
// TODO: This is supposed to be a tree-like structure, with directories containing files and playlists
|
||||
@@ -23,16 +19,17 @@ impl ListAllResponse {
|
||||
}
|
||||
|
||||
impl CommandResponse for ListAllResponse {
|
||||
type Request = ListAllRequest;
|
||||
|
||||
fn parse(parts: ResponseAttributes<'_>) -> Result<Self, ResponseParserError> {
|
||||
let result = DbSelectionPrintResponse::parse(parts)?;
|
||||
|
||||
Ok(ListAllResponse(result))
|
||||
}
|
||||
}
|
||||
|
||||
impl Command for ListAll {
|
||||
type Request = ListAllRequest;
|
||||
type Response = ListAllResponse;
|
||||
fn serialize(&self) -> Vec<u8> {
|
||||
unimplemented!("response serialization is not yet implemented for ListAllResponse")
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -64,7 +61,7 @@ mod tests {
|
||||
OK
|
||||
"};
|
||||
|
||||
let result = ListAll::parse_raw_response(response.as_bytes());
|
||||
let result = ListAllResponse::parse_raw(response.as_bytes());
|
||||
|
||||
assert_eq!(
|
||||
result,
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{
|
||||
Command, CommandResponse, ResponseParserError, single_optional_item_command_request,
|
||||
},
|
||||
commands::{CommandResponse, ResponseParserError, single_optional_item_command_request},
|
||||
response_tokenizer::ResponseAttributes,
|
||||
types::{DbSelectionPrintResponse, Uri},
|
||||
};
|
||||
|
||||
pub struct ListAllInfo;
|
||||
|
||||
single_optional_item_command_request!(ListAllInfo, "listallinfo", Uri);
|
||||
|
||||
// TODO: This is supposed to be a tree-like structure, with directories containing files and playlists
|
||||
@@ -23,16 +19,17 @@ impl ListAllInfoResponse {
|
||||
}
|
||||
|
||||
impl CommandResponse for ListAllInfoResponse {
|
||||
type Request = ListAllInfoRequest;
|
||||
|
||||
fn parse(parts: ResponseAttributes<'_>) -> Result<Self, ResponseParserError> {
|
||||
let result = DbSelectionPrintResponse::parse(parts)?;
|
||||
|
||||
Ok(ListAllInfoResponse(result))
|
||||
}
|
||||
}
|
||||
|
||||
impl Command for ListAllInfo {
|
||||
type Request = ListAllInfoRequest;
|
||||
type Response = ListAllInfoResponse;
|
||||
fn serialize(&self) -> Vec<u8> {
|
||||
unimplemented!("response serialization is not yet implemented for ListAllInfoResponse")
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -74,7 +71,7 @@ mod tests {
|
||||
OK
|
||||
"};
|
||||
|
||||
let result = ListAllInfo::parse_raw_response(response.as_bytes());
|
||||
let result = ListAllInfoResponse::parse_raw(response.as_bytes());
|
||||
|
||||
assert_eq!(
|
||||
result,
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{
|
||||
Command, CommandResponse, ResponseParserError, single_optional_item_command_request,
|
||||
},
|
||||
commands::{CommandResponse, ResponseParserError, single_optional_item_command_request},
|
||||
response_tokenizer::ResponseAttributes,
|
||||
types::{DbDirectoryInfo, DbSelectionPrintResponse, Uri},
|
||||
};
|
||||
|
||||
pub struct ListFiles;
|
||||
|
||||
single_optional_item_command_request!(ListFiles, "listfiles", Uri);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
@@ -22,6 +18,8 @@ impl ListFilesResponse {
|
||||
}
|
||||
|
||||
impl CommandResponse for ListFilesResponse {
|
||||
type Request = ListFilesRequest;
|
||||
|
||||
fn parse(parts: ResponseAttributes<'_>) -> Result<Self, ResponseParserError> {
|
||||
DbSelectionPrintResponse::parse(parts)?
|
||||
.into_iter()
|
||||
@@ -37,9 +35,8 @@ impl CommandResponse for ListFilesResponse {
|
||||
.collect::<Result<Vec<_>, ResponseParserError>>()
|
||||
.map(ListFilesResponse)
|
||||
}
|
||||
}
|
||||
|
||||
impl Command for ListFiles {
|
||||
type Request = ListFilesRequest;
|
||||
type Response = ListFilesResponse;
|
||||
fn serialize(&self) -> Vec<u8> {
|
||||
unimplemented!("response serialization is not yet implemented for ListFilesResponse")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{
|
||||
Command, CommandResponse, ResponseParserError, single_optional_item_command_request,
|
||||
},
|
||||
commands::{CommandResponse, ResponseParserError, single_optional_item_command_request},
|
||||
response_tokenizer::ResponseAttributes,
|
||||
types::{DbSelectionPrintResponse, Uri},
|
||||
};
|
||||
|
||||
pub struct LsInfo;
|
||||
|
||||
single_optional_item_command_request!(LsInfo, "lsinfo", Uri);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
@@ -22,16 +18,17 @@ impl LsInfoResponse {
|
||||
}
|
||||
|
||||
impl CommandResponse for LsInfoResponse {
|
||||
type Request = LsInfoRequest;
|
||||
|
||||
fn parse(parts: ResponseAttributes<'_>) -> Result<Self, ResponseParserError> {
|
||||
let result = DbSelectionPrintResponse::parse(parts)?;
|
||||
|
||||
Ok(LsInfoResponse(result))
|
||||
}
|
||||
}
|
||||
|
||||
impl Command for LsInfo {
|
||||
type Request = LsInfoRequest;
|
||||
type Response = LsInfoResponse;
|
||||
fn serialize(&self) -> Vec<u8> {
|
||||
unimplemented!("response serialization is not yet implemented for LsInfoResponse")
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -62,7 +59,7 @@ mod tests {
|
||||
OK
|
||||
"};
|
||||
|
||||
let result = LsInfo::parse_raw_response(response.as_bytes());
|
||||
let result = LsInfoResponse::parse_raw(response.as_bytes());
|
||||
|
||||
assert_eq!(
|
||||
result,
|
||||
|
||||
@@ -3,13 +3,11 @@ use std::collections::HashMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandResponse, ResponseParserError, single_item_command_request},
|
||||
commands::{CommandResponse, ResponseParserError, single_item_command_request},
|
||||
response_tokenizer::{GenericResponseValue, ResponseAttributes},
|
||||
types::Uri,
|
||||
};
|
||||
|
||||
pub struct ReadComments;
|
||||
|
||||
single_item_command_request!(ReadComments, "readcomments", Uri);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
@@ -22,6 +20,8 @@ impl ReadCommentsResponse {
|
||||
}
|
||||
|
||||
impl CommandResponse for ReadCommentsResponse {
|
||||
type Request = ReadCommentsRequest;
|
||||
|
||||
fn parse(parts: ResponseAttributes<'_>) -> Result<Self, ResponseParserError> {
|
||||
let parts: HashMap<_, _> = parts.into_map()?;
|
||||
|
||||
@@ -37,9 +37,8 @@ impl CommandResponse for ReadCommentsResponse {
|
||||
|
||||
Ok(ReadCommentsResponse(comments))
|
||||
}
|
||||
}
|
||||
|
||||
impl Command for ReadComments {
|
||||
type Request = ReadCommentsRequest;
|
||||
type Response = ReadCommentsResponse;
|
||||
fn serialize(&self) -> Vec<u8> {
|
||||
unimplemented!("response serialization is not yet implemented for ReadCommentsResponse")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::collections::HashMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandRequest, CommandResponse, RequestParserError, ResponseParserError},
|
||||
commands::{CommandRequest, CommandResponse, RequestParserError, ResponseParserError},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::{
|
||||
ResponseAttributes, get_and_parse_property, get_optional_property, get_property,
|
||||
@@ -11,8 +11,6 @@ use crate::{
|
||||
types::{Offset, Uri},
|
||||
};
|
||||
|
||||
pub struct ReadPicture;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct ReadPictureRequest {
|
||||
pub uri: Uri,
|
||||
@@ -26,6 +24,8 @@ impl ReadPictureRequest {
|
||||
}
|
||||
|
||||
impl CommandRequest for ReadPictureRequest {
|
||||
type Response = ReadPictureResponse;
|
||||
|
||||
const COMMAND: &'static str = "readpicture";
|
||||
const MIN_ARGS: u32 = 2;
|
||||
const MAX_ARGS: Option<u32> = Some(2);
|
||||
@@ -78,6 +78,8 @@ impl ReadPictureResponse {
|
||||
}
|
||||
|
||||
impl CommandResponse for ReadPictureResponse {
|
||||
type Request = ReadPictureRequest;
|
||||
|
||||
fn parse(parts: ResponseAttributes<'_>) -> Result<Self, ResponseParserError> {
|
||||
let parts: HashMap<_, _> = parts.into_map()?;
|
||||
|
||||
@@ -98,9 +100,8 @@ impl CommandResponse for ReadPictureResponse {
|
||||
mimetype,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl Command for ReadPicture {
|
||||
type Request = ReadPictureRequest;
|
||||
type Response = ReadPictureResponse;
|
||||
fn serialize(&self) -> Vec<u8> {
|
||||
unimplemented!("response serialization is not yet implemented for ReadPictureResponse")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,15 +3,11 @@ use std::collections::HashMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{
|
||||
Command, CommandResponse, ResponseParserError, single_optional_item_command_request,
|
||||
},
|
||||
commands::{CommandResponse, ResponseParserError, single_optional_item_command_request},
|
||||
response_tokenizer::{ResponseAttributes, get_and_parse_property},
|
||||
types::Uri,
|
||||
};
|
||||
|
||||
pub struct Rescan;
|
||||
|
||||
single_optional_item_command_request!(Rescan, "rescan", Uri);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
@@ -26,6 +22,8 @@ impl RescanResponse {
|
||||
}
|
||||
|
||||
impl CommandResponse for RescanResponse {
|
||||
type Request = RescanRequest;
|
||||
|
||||
fn parse(parts: ResponseAttributes<'_>) -> Result<Self, ResponseParserError> {
|
||||
let parts: HashMap<_, _> = parts.into_map()?;
|
||||
|
||||
@@ -33,9 +31,8 @@ impl CommandResponse for RescanResponse {
|
||||
|
||||
Ok(RescanResponse { updating_db })
|
||||
}
|
||||
}
|
||||
|
||||
impl Command for Rescan {
|
||||
type Request = RescanRequest;
|
||||
type Response = RescanResponse;
|
||||
fn serialize(&self) -> Vec<u8> {
|
||||
unimplemented!("response serialization is not yet implemented for RescanResponse")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandRequest, CommandResponse, RequestParserError, ResponseParserError},
|
||||
commands::{CommandRequest, CommandResponse, RequestParserError, ResponseParserError},
|
||||
filter::Filter,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
types::{DbSelectionPrintResponse, DbSongInfo, Sort, WindowRange},
|
||||
};
|
||||
|
||||
pub struct Search;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct SearchRequest {
|
||||
filter: Filter,
|
||||
@@ -28,6 +26,8 @@ impl SearchRequest {
|
||||
}
|
||||
|
||||
impl CommandRequest for SearchRequest {
|
||||
type Response = SearchResponse;
|
||||
|
||||
const COMMAND: &'static str = "search";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
const MAX_ARGS: Option<u32> = Some(3);
|
||||
@@ -113,6 +113,8 @@ impl SearchResponse {
|
||||
}
|
||||
|
||||
impl CommandResponse for SearchResponse {
|
||||
type Request = SearchRequest;
|
||||
|
||||
fn parse(parts: ResponseAttributes<'_>) -> Result<Self, ResponseParserError> {
|
||||
DbSelectionPrintResponse::parse(parts)?
|
||||
.into_iter()
|
||||
@@ -128,9 +130,8 @@ impl CommandResponse for SearchResponse {
|
||||
.collect::<Result<Vec<DbSongInfo>, ResponseParserError>>()
|
||||
.map(SearchResponse)
|
||||
}
|
||||
}
|
||||
|
||||
impl Command for Search {
|
||||
type Request = SearchRequest;
|
||||
type Response = SearchResponse;
|
||||
fn serialize(&self) -> Vec<u8> {
|
||||
unimplemented!("response serialization is not yet implemented for SearchResponse")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandRequest, RequestParserError, empty_command_response},
|
||||
commands::{CommandRequest, RequestParserError, empty_command_response},
|
||||
filter::Filter,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
types::{SongPosition, Sort, WindowRange},
|
||||
};
|
||||
|
||||
pub struct SearchAdd;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct SearchAddRequest {
|
||||
filter: Filter,
|
||||
@@ -34,6 +32,8 @@ impl SearchAddRequest {
|
||||
}
|
||||
|
||||
impl CommandRequest for SearchAddRequest {
|
||||
type Response = SearchAddResponse;
|
||||
|
||||
const COMMAND: &'static str = "searchadd";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
const MAX_ARGS: Option<u32> = Some(4);
|
||||
@@ -134,8 +134,3 @@ impl CommandRequest for SearchAddRequest {
|
||||
}
|
||||
|
||||
empty_command_response!(SearchAdd);
|
||||
|
||||
impl Command for SearchAdd {
|
||||
type Request = SearchAddRequest;
|
||||
type Response = SearchAddResponse;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandRequest, RequestParserError, empty_command_response},
|
||||
commands::{CommandRequest, RequestParserError, empty_command_response},
|
||||
filter::Filter,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
types::{PlaylistName, SongPosition, Sort, WindowRange},
|
||||
};
|
||||
|
||||
pub struct SearchAddPl;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct SearchAddPlRequest {
|
||||
playlist_name: PlaylistName,
|
||||
@@ -37,6 +35,8 @@ impl SearchAddPlRequest {
|
||||
}
|
||||
|
||||
impl CommandRequest for SearchAddPlRequest {
|
||||
type Response = SearchAddPlResponse;
|
||||
|
||||
const COMMAND: &'static str = "searchaddpl";
|
||||
const MIN_ARGS: u32 = 2;
|
||||
const MAX_ARGS: Option<u32> = Some(5);
|
||||
@@ -143,8 +143,3 @@ impl CommandRequest for SearchAddPlRequest {
|
||||
}
|
||||
|
||||
empty_command_response!(SearchAddPl);
|
||||
|
||||
impl Command for SearchAddPl {
|
||||
type Request = SearchAddPlRequest;
|
||||
type Response = SearchAddPlResponse;
|
||||
}
|
||||
|
||||
@@ -3,15 +3,13 @@ use std::collections::HashMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandRequest, CommandResponse, RequestParserError, ResponseParserError},
|
||||
commands::{CommandRequest, CommandResponse, RequestParserError, ResponseParserError},
|
||||
filter::Filter,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::{ResponseAttributes, get_and_parse_property},
|
||||
types::{GroupType, Seconds},
|
||||
};
|
||||
|
||||
pub struct SearchCount;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct SearchCountRequest {
|
||||
filter: Filter,
|
||||
@@ -25,6 +23,8 @@ impl SearchCountRequest {
|
||||
}
|
||||
|
||||
impl CommandRequest for SearchCountRequest {
|
||||
type Response = SearchCountResponse;
|
||||
|
||||
const COMMAND: &'static str = "searchcount";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
const MAX_ARGS: Option<u32> = Some(2);
|
||||
@@ -85,6 +85,8 @@ impl SearchCountResponse {
|
||||
}
|
||||
|
||||
impl CommandResponse for SearchCountResponse {
|
||||
type Request = SearchCountRequest;
|
||||
|
||||
fn parse(parts: ResponseAttributes<'_>) -> Result<Self, ResponseParserError> {
|
||||
let parts: HashMap<_, _> = parts.into_map()?;
|
||||
|
||||
@@ -93,9 +95,8 @@ impl CommandResponse for SearchCountResponse {
|
||||
|
||||
Ok(SearchCountResponse { songs, playtime })
|
||||
}
|
||||
}
|
||||
|
||||
impl Command for SearchCount {
|
||||
type Request = SearchCountRequest;
|
||||
type Response = SearchCountResponse;
|
||||
fn serialize(&self) -> Vec<u8> {
|
||||
unimplemented!("response serialization is not yet implemented for SearchCountResponse")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,15 +3,11 @@ use std::collections::HashMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{
|
||||
Command, CommandResponse, ResponseParserError, single_optional_item_command_request,
|
||||
},
|
||||
commands::{CommandResponse, ResponseParserError, single_optional_item_command_request},
|
||||
response_tokenizer::{ResponseAttributes, get_and_parse_property},
|
||||
types::Uri,
|
||||
};
|
||||
|
||||
pub struct Update;
|
||||
|
||||
single_optional_item_command_request!(Update, "update", Uri);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
@@ -26,6 +22,8 @@ impl UpdateResponse {
|
||||
}
|
||||
|
||||
impl CommandResponse for UpdateResponse {
|
||||
type Request = UpdateRequest;
|
||||
|
||||
fn parse(parts: ResponseAttributes<'_>) -> Result<Self, ResponseParserError> {
|
||||
let parts: HashMap<_, _> = parts.into_map()?;
|
||||
|
||||
@@ -33,9 +31,8 @@ impl CommandResponse for UpdateResponse {
|
||||
|
||||
Ok(UpdateResponse { updating_db })
|
||||
}
|
||||
}
|
||||
|
||||
impl Command for Update {
|
||||
type Request = UpdateRequest;
|
||||
type Response = UpdateResponse;
|
||||
fn serialize(&self) -> Vec<u8> {
|
||||
unimplemented!("response serialization is not yet implemented for UpdateResponse")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
use crate::{
|
||||
commands::{Command, empty_command_response, single_item_command_request},
|
||||
commands::{empty_command_response, single_item_command_request},
|
||||
types::PartitionName,
|
||||
};
|
||||
|
||||
pub struct DelPartition;
|
||||
|
||||
single_item_command_request!(DelPartition, "delpartition", PartitionName);
|
||||
|
||||
empty_command_response!(DelPartition);
|
||||
|
||||
impl Command for DelPartition {
|
||||
type Request = DelPartitionRequest;
|
||||
type Response = DelPartitionResponse;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,9 @@
|
||||
use crate::{
|
||||
commands::{Command, ResponseParserError, empty_command_request, multi_item_command_response},
|
||||
commands::{ResponseParserError, empty_command_request, multi_item_command_response},
|
||||
response_tokenizer::expect_property_type,
|
||||
types::PartitionName,
|
||||
};
|
||||
|
||||
pub struct ListPartitions;
|
||||
|
||||
empty_command_request!(ListPartitions, "listpartitions");
|
||||
|
||||
multi_item_command_response!(ListPartitions, "partition", PartitionName);
|
||||
|
||||
impl Command for ListPartitions {
|
||||
type Request = ListPartitionsRequest;
|
||||
type Response = ListPartitionsResponse;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
use crate::commands::{Command, empty_command_response, single_item_command_request};
|
||||
|
||||
pub struct MoveOutput;
|
||||
use crate::commands::{empty_command_response, single_item_command_request};
|
||||
|
||||
single_item_command_request!(MoveOutput, "moveoutput", String);
|
||||
|
||||
empty_command_response!(MoveOutput);
|
||||
|
||||
impl Command for MoveOutput {
|
||||
type Request = MoveOutputRequest;
|
||||
type Response = MoveOutputResponse;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
use crate::{
|
||||
commands::{Command, empty_command_response, single_item_command_request},
|
||||
commands::{empty_command_response, single_item_command_request},
|
||||
types::PartitionName,
|
||||
};
|
||||
|
||||
pub struct NewPartition;
|
||||
|
||||
single_item_command_request!(NewPartition, "newpartition", PartitionName);
|
||||
|
||||
empty_command_response!(NewPartition);
|
||||
|
||||
impl Command for NewPartition {
|
||||
type Request = NewPartitionRequest;
|
||||
type Response = NewPartitionResponse;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
use crate::{
|
||||
commands::{Command, empty_command_response, single_item_command_request},
|
||||
commands::{empty_command_response, single_item_command_request},
|
||||
types::PartitionName,
|
||||
};
|
||||
|
||||
pub struct Partition;
|
||||
|
||||
single_item_command_request!(Partition, "partition", PartitionName);
|
||||
|
||||
empty_command_response!(Partition);
|
||||
|
||||
impl Command for Partition {
|
||||
type Request = PartitionRequest;
|
||||
type Response = PartitionResponse;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
use crate::{
|
||||
commands::{Command, empty_command_response, single_item_command_request},
|
||||
commands::{empty_command_response, single_item_command_request},
|
||||
types::BoolOrOneshot,
|
||||
};
|
||||
|
||||
pub struct Consume;
|
||||
|
||||
single_item_command_request!(Consume, "consume", BoolOrOneshot);
|
||||
|
||||
empty_command_response!(Consume);
|
||||
|
||||
impl Command for Consume {
|
||||
type Request = ConsumeRequest;
|
||||
type Response = ConsumeResponse;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
use crate::{
|
||||
commands::{Command, empty_command_response, single_item_command_request},
|
||||
commands::{empty_command_response, single_item_command_request},
|
||||
types::Seconds,
|
||||
};
|
||||
|
||||
pub struct Crossfade;
|
||||
|
||||
single_item_command_request!(Crossfade, "crossfade", Seconds);
|
||||
|
||||
empty_command_response!(Crossfade);
|
||||
|
||||
impl Command for Crossfade {
|
||||
type Request = CrossfadeRequest;
|
||||
type Response = CrossfadeResponse;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
use crate::{
|
||||
commands::{Command, empty_command_request, single_item_command_response},
|
||||
commands::{empty_command_request, single_item_command_response},
|
||||
types::VolumeValue,
|
||||
};
|
||||
|
||||
pub struct GetVol;
|
||||
|
||||
empty_command_request!(GetVol, "getvol");
|
||||
|
||||
single_item_command_response!(GetVol, "volume", VolumeValue);
|
||||
|
||||
impl Command for GetVol {
|
||||
type Request = GetVolRequest;
|
||||
type Response = GetVolResponse;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
use crate::commands::{Command, empty_command_response, single_item_command_request};
|
||||
|
||||
pub struct MixRampDb;
|
||||
use crate::commands::{empty_command_response, single_item_command_request};
|
||||
|
||||
single_item_command_request!(MixRampDb, "mixrampdb", f32);
|
||||
|
||||
empty_command_response!(MixRampDb);
|
||||
|
||||
impl Command for MixRampDb {
|
||||
type Request = MixRampDbRequest;
|
||||
type Response = MixRampDbResponse;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
use crate::{
|
||||
commands::{Command, empty_command_response, single_item_command_request},
|
||||
commands::{empty_command_response, single_item_command_request},
|
||||
types::Seconds,
|
||||
};
|
||||
|
||||
pub struct MixRampDelay;
|
||||
|
||||
single_item_command_request!(MixRampDelay, "mixrampdelay", Seconds);
|
||||
|
||||
empty_command_response!(MixRampDelay);
|
||||
|
||||
impl Command for MixRampDelay {
|
||||
type Request = MixRampDelayRequest;
|
||||
type Response = MixRampDelayResponse;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
use crate::{
|
||||
commands::{Command, CommandRequest, RequestParserError, empty_command_response},
|
||||
commands::{CommandRequest, RequestParserError, empty_command_response},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
};
|
||||
|
||||
pub struct Random;
|
||||
|
||||
pub struct RandomRequest(bool);
|
||||
|
||||
impl RandomRequest {
|
||||
@@ -14,6 +12,8 @@ impl RandomRequest {
|
||||
}
|
||||
|
||||
impl CommandRequest for RandomRequest {
|
||||
type Response = RandomResponse;
|
||||
|
||||
const COMMAND: &'static str = "random";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
const MAX_ARGS: Option<u32> = Some(1);
|
||||
@@ -44,8 +44,3 @@ impl CommandRequest for RandomRequest {
|
||||
}
|
||||
|
||||
empty_command_response!(Random);
|
||||
|
||||
impl Command for Random {
|
||||
type Request = RandomRequest;
|
||||
type Response = RandomResponse;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
use crate::{
|
||||
commands::{Command, CommandRequest, RequestParserError, empty_command_response},
|
||||
commands::{CommandRequest, RequestParserError, empty_command_response},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
};
|
||||
|
||||
pub struct Repeat;
|
||||
|
||||
pub struct RepeatRequest(bool);
|
||||
|
||||
impl RepeatRequest {
|
||||
@@ -14,6 +12,8 @@ impl RepeatRequest {
|
||||
}
|
||||
|
||||
impl CommandRequest for RepeatRequest {
|
||||
type Response = RepeatResponse;
|
||||
|
||||
const COMMAND: &'static str = "repeat";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
const MAX_ARGS: Option<u32> = Some(1);
|
||||
@@ -44,8 +44,3 @@ impl CommandRequest for RepeatRequest {
|
||||
}
|
||||
|
||||
empty_command_response!(Repeat);
|
||||
|
||||
impl Command for Repeat {
|
||||
type Request = RepeatRequest;
|
||||
type Response = RepeatResponse;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
use crate::{
|
||||
commands::{Command, empty_command_response, single_item_command_request},
|
||||
commands::{empty_command_response, single_item_command_request},
|
||||
types::ReplayGainModeMode,
|
||||
};
|
||||
|
||||
pub struct ReplayGainMode;
|
||||
|
||||
single_item_command_request!(ReplayGainMode, "replay_gain_mode", ReplayGainModeMode);
|
||||
|
||||
empty_command_response!(ReplayGainMode);
|
||||
|
||||
impl Command for ReplayGainMode {
|
||||
type Request = ReplayGainModeRequest;
|
||||
type Response = ReplayGainModeResponse;
|
||||
}
|
||||
|
||||
@@ -3,13 +3,11 @@ use std::{collections::HashMap, str::FromStr};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandResponse, ResponseParserError, empty_command_request},
|
||||
commands::{CommandResponse, ResponseParserError, empty_command_request},
|
||||
response_tokenizer::{ResponseAttributes, get_property},
|
||||
types::ReplayGainModeMode,
|
||||
};
|
||||
|
||||
pub struct ReplayGainStatus;
|
||||
|
||||
empty_command_request!(ReplayGainStatus, "replay_gain_status");
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
@@ -24,6 +22,8 @@ impl ReplayGainStatusResponse {
|
||||
}
|
||||
|
||||
impl CommandResponse for ReplayGainStatusResponse {
|
||||
type Request = ReplayGainStatusRequest;
|
||||
|
||||
fn parse(parts: ResponseAttributes<'_>) -> Result<Self, ResponseParserError> {
|
||||
let parts: HashMap<_, _> = parts.into_map()?;
|
||||
let replay_gain_mode = get_property!(parts, "replay_gain_mode", Text);
|
||||
@@ -37,9 +37,8 @@ impl CommandResponse for ReplayGainStatusResponse {
|
||||
})?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl Command for ReplayGainStatus {
|
||||
type Request = ReplayGainStatusRequest;
|
||||
type Response = ReplayGainStatusResponse;
|
||||
fn serialize(&self) -> Vec<u8> {
|
||||
unimplemented!("response serialization is not yet implemented for ReplayGainStatusResponse")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
use crate::{
|
||||
commands::{Command, empty_command_response, single_item_command_request},
|
||||
commands::{empty_command_response, single_item_command_request},
|
||||
types::VolumeValue,
|
||||
};
|
||||
|
||||
pub struct SetVol;
|
||||
|
||||
single_item_command_request!(SetVol, "setvol", VolumeValue);
|
||||
|
||||
empty_command_response!(SetVol);
|
||||
|
||||
impl Command for SetVol {
|
||||
type Request = SetVolRequest;
|
||||
type Response = SetVolResponse;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
use crate::{
|
||||
commands::{Command, empty_command_response, single_item_command_request},
|
||||
commands::{empty_command_response, single_item_command_request},
|
||||
types::BoolOrOneshot,
|
||||
};
|
||||
|
||||
pub struct Single;
|
||||
|
||||
single_item_command_request!(Single, "single", BoolOrOneshot);
|
||||
|
||||
empty_command_response!(Single);
|
||||
|
||||
impl Command for Single {
|
||||
type Request = SingleRequest;
|
||||
type Response = SingleResponse;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
use crate::{
|
||||
commands::{Command, empty_command_response, single_item_command_request},
|
||||
commands::{empty_command_response, single_item_command_request},
|
||||
types::VolumeValue,
|
||||
};
|
||||
|
||||
pub struct Volume;
|
||||
|
||||
single_item_command_request!(Volume, "volume", VolumeValue);
|
||||
|
||||
empty_command_response!(Volume);
|
||||
|
||||
impl Command for Volume {
|
||||
type Request = VolumeRequest;
|
||||
type Response = VolumeResponse;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
use crate::commands::{Command, empty_command_request, empty_command_response};
|
||||
|
||||
/// Clears the current error message in status (this is also accomplished by any command that starts playback)
|
||||
pub struct ClearError;
|
||||
use crate::commands::{empty_command_request, empty_command_response};
|
||||
|
||||
// Clears the current error message in status (this is also accomplished by any command that starts playback)
|
||||
empty_command_request!(ClearError, "clearerror");
|
||||
|
||||
empty_command_response!(ClearError);
|
||||
|
||||
impl Command for ClearError {
|
||||
type Request = ClearErrorRequest;
|
||||
type Response = ClearErrorResponse;
|
||||
}
|
||||
|
||||
@@ -3,16 +3,14 @@ use std::collections::HashMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandResponse, ResponseParserError, empty_command_request},
|
||||
commands::{CommandResponse, ResponseParserError, empty_command_request},
|
||||
response_tokenizer::{
|
||||
ResponseAttributes, get_and_parse_optional_property, get_and_parse_property,
|
||||
},
|
||||
types::{DbSongInfo, Priority, SongId, SongPosition},
|
||||
};
|
||||
|
||||
/// Displays the song info of the current song (same song that is identified in status)
|
||||
pub struct CurrentSong;
|
||||
|
||||
// Displays the song info of the current song (same song that is identified in status)
|
||||
empty_command_request!(CurrentSong, "currentsong");
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
@@ -40,6 +38,8 @@ impl CurrentSongResponse {
|
||||
}
|
||||
|
||||
impl CommandResponse for CurrentSongResponse {
|
||||
type Request = CurrentSongRequest;
|
||||
|
||||
fn parse(parts: ResponseAttributes<'_>) -> Result<Self, ResponseParserError> {
|
||||
let mut parts: HashMap<_, _> = parts.into_map()?;
|
||||
|
||||
@@ -60,9 +60,8 @@ impl CommandResponse for CurrentSongResponse {
|
||||
song_info,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl Command for CurrentSong {
|
||||
type Request = CurrentSongRequest;
|
||||
type Response = CurrentSongResponse;
|
||||
fn serialize(&self) -> Vec<u8> {
|
||||
unimplemented!("response serialization is not yet implemented for CurrentSongResponse")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
use std::str::FromStr;
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandRequest, RequestParserError, empty_command_response},
|
||||
commands::{CommandRequest, RequestParserError, empty_command_response},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
types::SubSystem,
|
||||
};
|
||||
|
||||
pub struct Idle;
|
||||
|
||||
pub struct IdleRequest(Option<Vec<SubSystem>>);
|
||||
|
||||
impl IdleRequest {
|
||||
@@ -17,6 +15,8 @@ impl IdleRequest {
|
||||
}
|
||||
|
||||
impl CommandRequest for IdleRequest {
|
||||
type Response = IdleResponse;
|
||||
|
||||
const COMMAND: &'static str = "idle";
|
||||
const MIN_ARGS: u32 = 0;
|
||||
const MAX_ARGS: Option<u32> = None;
|
||||
@@ -50,8 +50,3 @@ impl CommandRequest for IdleRequest {
|
||||
}
|
||||
|
||||
empty_command_response!(Idle);
|
||||
|
||||
impl Command for Idle {
|
||||
type Request = IdleRequest;
|
||||
type Response = IdleResponse;
|
||||
}
|
||||
|
||||
@@ -3,14 +3,12 @@ use std::collections::HashMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandResponse, ResponseParserError, empty_command_request},
|
||||
commands::{CommandResponse, ResponseParserError, empty_command_request},
|
||||
response_tokenizer::{
|
||||
ResponseAttributes, get_and_parse_optional_property, get_and_parse_property,
|
||||
},
|
||||
};
|
||||
|
||||
pub struct Stats;
|
||||
|
||||
empty_command_request!(Stats, "stats");
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
@@ -47,6 +45,8 @@ impl StatsResponse {
|
||||
}
|
||||
|
||||
impl CommandResponse for StatsResponse {
|
||||
type Request = StatsRequest;
|
||||
|
||||
fn parse(parts: ResponseAttributes<'_>) -> Result<Self, ResponseParserError> {
|
||||
let parts: HashMap<_, _> = parts.into_map()?;
|
||||
|
||||
@@ -68,9 +68,8 @@ impl CommandResponse for StatsResponse {
|
||||
db_update,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl Command for Stats {
|
||||
type Request = StatsRequest;
|
||||
type Response = StatsResponse;
|
||||
fn serialize(&self) -> Vec<u8> {
|
||||
unimplemented!("response serialization is not yet implemented for StatsResponse")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ use std::str::FromStr;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandResponse, ResponseParserError, empty_command_request},
|
||||
commands::{CommandResponse, ResponseParserError, empty_command_request},
|
||||
response_tokenizer::{
|
||||
ResponseAttributes, get_and_parse_optional_property, get_and_parse_property,
|
||||
get_optional_property, get_property,
|
||||
@@ -12,8 +12,6 @@ use crate::{
|
||||
types::{Audio, BoolOrOneshot, SongId, SongPosition},
|
||||
};
|
||||
|
||||
pub struct Status;
|
||||
|
||||
empty_command_request!(Status, "status");
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
@@ -122,6 +120,8 @@ impl StatusResponse {
|
||||
}
|
||||
|
||||
impl CommandResponse for StatusResponse {
|
||||
type Request = StatusRequest;
|
||||
|
||||
fn parse(parts: ResponseAttributes<'_>) -> Result<Self, ResponseParserError> {
|
||||
let parts: HashMap<_, _> = parts.into_map()?;
|
||||
let partition = get_property!(parts, "partition", Text).to_string();
|
||||
@@ -224,11 +224,10 @@ impl CommandResponse for StatusResponse {
|
||||
last_loaded_playlist,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl Command for Status {
|
||||
type Request = StatusRequest;
|
||||
type Response = StatusResponse;
|
||||
fn serialize(&self) -> Vec<u8> {
|
||||
unimplemented!("response serialization is not yet implemented for StatusResponse")
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -263,7 +262,7 @@ mod tests {
|
||||
"# };
|
||||
|
||||
assert_eq!(
|
||||
Status::parse_raw_response(contents.as_bytes()),
|
||||
StatusResponse::parse_raw(contents.as_bytes()),
|
||||
Ok(StatusResponse {
|
||||
partition: "default".into(),
|
||||
volume: Some(66),
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandRequest, RequestParserError, empty_command_response},
|
||||
commands::{CommandRequest, RequestParserError, empty_command_response},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
types::{SongPosition, Uri},
|
||||
};
|
||||
|
||||
pub struct Add;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct AddRequest {
|
||||
uri: Uri,
|
||||
@@ -21,6 +19,8 @@ impl AddRequest {
|
||||
}
|
||||
|
||||
impl CommandRequest for AddRequest {
|
||||
type Response = AddResponse;
|
||||
|
||||
const COMMAND: &'static str = "add";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
const MAX_ARGS: Option<u32> = Some(2);
|
||||
@@ -59,8 +59,3 @@ impl CommandRequest for AddRequest {
|
||||
}
|
||||
|
||||
empty_command_response!(Add);
|
||||
|
||||
impl Command for Add {
|
||||
type Request = AddRequest;
|
||||
type Response = AddResponse;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandRequest, CommandResponse, RequestParserError, ResponseParserError},
|
||||
commands::{CommandRequest, CommandResponse, RequestParserError, ResponseParserError},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::{ResponseAttributes, get_next_and_parse_property},
|
||||
types::{SongId, SongPosition, Uri},
|
||||
};
|
||||
|
||||
pub struct AddId;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct AddIdRequest {
|
||||
pub uri: Uri,
|
||||
@@ -22,6 +20,8 @@ impl AddIdRequest {
|
||||
}
|
||||
|
||||
impl CommandRequest for AddIdRequest {
|
||||
type Response = AddIdResponse;
|
||||
|
||||
const COMMAND: &'static str = "addid";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
const MAX_ARGS: Option<u32> = Some(2);
|
||||
@@ -71,6 +71,8 @@ impl AddIdResponse {
|
||||
}
|
||||
|
||||
impl CommandResponse for AddIdResponse {
|
||||
type Request = AddIdRequest;
|
||||
|
||||
fn parse(parts: ResponseAttributes<'_>) -> Result<Self, ResponseParserError> {
|
||||
let parts: Vec<_> = parts.into();
|
||||
let mut iter = parts.into_iter();
|
||||
@@ -80,9 +82,8 @@ impl CommandResponse for AddIdResponse {
|
||||
}
|
||||
Ok(AddIdResponse { id })
|
||||
}
|
||||
}
|
||||
|
||||
impl Command for AddId {
|
||||
type Request = AddIdRequest;
|
||||
type Response = AddIdResponse;
|
||||
fn serialize(&self) -> Vec<u8> {
|
||||
unimplemented!("response serialization is not yet implemented for AddIdResponse")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandRequest, RequestParserError, empty_command_response},
|
||||
commands::{CommandRequest, RequestParserError, empty_command_response},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
types::{SongId, TagName, TagValue},
|
||||
};
|
||||
|
||||
pub struct AddTagId;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct AddTagIdRequest {
|
||||
pub songid: SongId,
|
||||
@@ -26,6 +24,8 @@ impl AddTagIdRequest {
|
||||
}
|
||||
|
||||
impl CommandRequest for AddTagIdRequest {
|
||||
type Response = AddTagIdResponse;
|
||||
|
||||
const COMMAND: &'static str = "addtagid";
|
||||
const MIN_ARGS: u32 = 3;
|
||||
const MAX_ARGS: Option<u32> = Some(3);
|
||||
@@ -79,8 +79,3 @@ impl CommandRequest for AddTagIdRequest {
|
||||
}
|
||||
|
||||
empty_command_response!(AddTagId);
|
||||
|
||||
impl Command for AddTagId {
|
||||
type Request = AddTagIdRequest;
|
||||
type Response = AddTagIdResponse;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
use crate::commands::{Command, empty_command_request, empty_command_response};
|
||||
|
||||
pub struct Clear;
|
||||
use crate::commands::{empty_command_request, empty_command_response};
|
||||
|
||||
empty_command_request!(Clear, "clear");
|
||||
|
||||
empty_command_response!(Clear);
|
||||
|
||||
impl Command for Clear {
|
||||
type Request = ClearRequest;
|
||||
type Response = ClearResponse;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandRequest, RequestParserError, empty_command_response},
|
||||
commands::{CommandRequest, RequestParserError, empty_command_response},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
types::{SongId, TagName},
|
||||
};
|
||||
|
||||
pub struct ClearTagId;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct ClearTagIdRequest {
|
||||
pub songid: SongId,
|
||||
@@ -21,6 +19,8 @@ impl ClearTagIdRequest {
|
||||
}
|
||||
|
||||
impl CommandRequest for ClearTagIdRequest {
|
||||
type Response = ClearTagIdResponse;
|
||||
|
||||
const COMMAND: &'static str = "cleartagid";
|
||||
const MIN_ARGS: u32 = 2;
|
||||
const MAX_ARGS: Option<u32> = Some(2);
|
||||
@@ -55,8 +55,3 @@ impl CommandRequest for ClearTagIdRequest {
|
||||
}
|
||||
|
||||
empty_command_response!(ClearTagId);
|
||||
|
||||
impl Command for ClearTagId {
|
||||
type Request = ClearTagIdRequest;
|
||||
type Response = ClearTagIdResponse;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
use crate::{
|
||||
commands::{Command, empty_command_response, single_item_command_request},
|
||||
commands::{empty_command_response, single_item_command_request},
|
||||
types::OneOrRange,
|
||||
};
|
||||
|
||||
pub struct Delete;
|
||||
|
||||
single_item_command_request!(Delete, "delete", OneOrRange);
|
||||
|
||||
empty_command_response!(Delete);
|
||||
|
||||
impl Command for Delete {
|
||||
type Request = DeleteRequest;
|
||||
type Response = DeleteResponse;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
use crate::{
|
||||
commands::{Command, empty_command_response, single_item_command_request},
|
||||
commands::{empty_command_response, single_item_command_request},
|
||||
types::SongId,
|
||||
};
|
||||
|
||||
pub struct DeleteId;
|
||||
|
||||
single_item_command_request!(DeleteId, "deleteid", SongId);
|
||||
|
||||
empty_command_response!(DeleteId);
|
||||
|
||||
impl Command for DeleteId {
|
||||
type Request = DeleteIdRequest;
|
||||
type Response = DeleteIdResponse;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandRequest, RequestParserError, empty_command_response},
|
||||
commands::{CommandRequest, RequestParserError, empty_command_response},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
types::{AbsouluteRelativeSongPosition, OneOrRange},
|
||||
};
|
||||
|
||||
pub struct Move;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct MoveRequest {
|
||||
pub from_or_range: OneOrRange,
|
||||
@@ -21,6 +19,8 @@ impl MoveRequest {
|
||||
}
|
||||
|
||||
impl CommandRequest for MoveRequest {
|
||||
type Response = MoveResponse;
|
||||
|
||||
const COMMAND: &'static str = "move";
|
||||
const MIN_ARGS: u32 = 2;
|
||||
const MAX_ARGS: Option<u32> = Some(2);
|
||||
@@ -56,8 +56,3 @@ impl CommandRequest for MoveRequest {
|
||||
}
|
||||
|
||||
empty_command_response!(Move);
|
||||
|
||||
impl Command for Move {
|
||||
type Request = MoveRequest;
|
||||
type Response = MoveResponse;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandRequest, RequestParserError, empty_command_response},
|
||||
commands::{CommandRequest, RequestParserError, empty_command_response},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
types::{AbsouluteRelativeSongPosition, SongId},
|
||||
};
|
||||
|
||||
pub struct MoveId;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct MoveIdRequest {
|
||||
pub id: SongId,
|
||||
@@ -21,6 +19,8 @@ impl MoveIdRequest {
|
||||
}
|
||||
|
||||
impl CommandRequest for MoveIdRequest {
|
||||
type Response = MoveIdResponse;
|
||||
|
||||
const COMMAND: &'static str = "moveid";
|
||||
const MIN_ARGS: u32 = 2;
|
||||
const MAX_ARGS: Option<u32> = Some(2);
|
||||
@@ -55,8 +55,3 @@ impl CommandRequest for MoveIdRequest {
|
||||
}
|
||||
|
||||
empty_command_response!(MoveId);
|
||||
|
||||
impl Command for MoveId {
|
||||
type Request = MoveIdRequest;
|
||||
type Response = MoveIdResponse;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandResponse, ResponseParserError, empty_command_request},
|
||||
commands::{CommandResponse, ResponseParserError, empty_command_request},
|
||||
response_tokenizer::ResponseAttributes,
|
||||
types::Uri,
|
||||
};
|
||||
|
||||
pub struct Playlist;
|
||||
|
||||
empty_command_request!(Playlist, "playlist");
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
@@ -20,12 +18,13 @@ impl PlaylistResponse {
|
||||
}
|
||||
|
||||
impl CommandResponse for PlaylistResponse {
|
||||
type Request = PlaylistRequest;
|
||||
|
||||
fn parse(_parts: ResponseAttributes<'_>) -> Result<Self, ResponseParserError> {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
impl Command for Playlist {
|
||||
type Request = PlaylistRequest;
|
||||
type Response = PlaylistResponse;
|
||||
fn serialize(&self) -> Vec<u8> {
|
||||
unimplemented!("response serialization is not yet implemented for PlaylistResponse")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandRequest, CommandResponse, RequestParserError, ResponseParserError},
|
||||
commands::{CommandRequest, CommandResponse, RequestParserError, ResponseParserError},
|
||||
filter::Filter,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
types::{DbSongInfo, Priority, SongId, SongPosition, Sort, WindowRange},
|
||||
};
|
||||
|
||||
pub struct PlaylistFind;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct PlaylistFindRequest {
|
||||
filter: Filter,
|
||||
@@ -28,6 +26,8 @@ impl PlaylistFindRequest {
|
||||
}
|
||||
|
||||
impl CommandRequest for PlaylistFindRequest {
|
||||
type Response = PlaylistFindResponse;
|
||||
|
||||
const COMMAND: &'static str = "playlistfind";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
const MAX_ARGS: Option<u32> = Some(3);
|
||||
@@ -137,12 +137,13 @@ impl PlaylistFindResponseEntry {
|
||||
}
|
||||
|
||||
impl CommandResponse for PlaylistFindResponse {
|
||||
type Request = PlaylistFindRequest;
|
||||
|
||||
fn parse(_parts: ResponseAttributes<'_>) -> Result<Self, ResponseParserError> {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
impl Command for PlaylistFind {
|
||||
type Request = PlaylistFindRequest;
|
||||
type Response = PlaylistFindResponse;
|
||||
fn serialize(&self) -> Vec<u8> {
|
||||
unimplemented!("response serialization is not yet implemented for PlaylistFindResponse")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandResponse, ResponseParserError, single_item_command_request},
|
||||
commands::{CommandResponse, ResponseParserError, single_item_command_request},
|
||||
response_tokenizer::ResponseAttributes,
|
||||
types::{DbSongInfo, Priority, SongId, SongPosition},
|
||||
};
|
||||
|
||||
pub struct PlaylistId;
|
||||
|
||||
single_item_command_request!(PlaylistId, "playlistid", SongId);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
@@ -44,12 +42,13 @@ impl PlaylistIdResponseEntry {
|
||||
}
|
||||
|
||||
impl CommandResponse for PlaylistIdResponse {
|
||||
type Request = PlaylistIdRequest;
|
||||
|
||||
fn parse(_parts: ResponseAttributes<'_>) -> Result<Self, ResponseParserError> {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
impl Command for PlaylistId {
|
||||
type Request = PlaylistIdRequest;
|
||||
type Response = PlaylistIdResponse;
|
||||
fn serialize(&self) -> Vec<u8> {
|
||||
unimplemented!("response serialization is not yet implemented for PlaylistIdResponse")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{
|
||||
Command, CommandResponse, ResponseParserError, single_optional_item_command_request,
|
||||
},
|
||||
commands::{CommandResponse, ResponseParserError, single_optional_item_command_request},
|
||||
response_tokenizer::ResponseAttributes,
|
||||
types::{DbSongInfo, OneOrRange, Priority, SongId, SongPosition},
|
||||
};
|
||||
|
||||
pub struct PlaylistInfo;
|
||||
|
||||
single_optional_item_command_request!(PlaylistInfo, "playlistinfo", OneOrRange);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
@@ -46,12 +42,13 @@ impl PlaylistInfoResponseEntry {
|
||||
}
|
||||
|
||||
impl CommandResponse for PlaylistInfoResponse {
|
||||
type Request = PlaylistInfoRequest;
|
||||
|
||||
fn parse(_parts: ResponseAttributes<'_>) -> Result<Self, ResponseParserError> {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
impl Command for PlaylistInfo {
|
||||
type Request = PlaylistInfoRequest;
|
||||
type Response = PlaylistInfoResponse;
|
||||
fn serialize(&self) -> Vec<u8> {
|
||||
unimplemented!("response serialization is not yet implemented for PlaylistInfoResponse")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandRequest, CommandResponse, RequestParserError, ResponseParserError},
|
||||
commands::{CommandRequest, CommandResponse, RequestParserError, ResponseParserError},
|
||||
filter::Filter,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
types::{DbSongInfo, Priority, SongId, SongPosition, Sort, WindowRange},
|
||||
};
|
||||
|
||||
pub struct PlaylistSearch;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct PlaylistSearchRequest {
|
||||
filter: Filter,
|
||||
@@ -28,6 +26,8 @@ impl PlaylistSearchRequest {
|
||||
}
|
||||
|
||||
impl CommandRequest for PlaylistSearchRequest {
|
||||
type Response = PlaylistSearchResponse;
|
||||
|
||||
const COMMAND: &'static str = "playlistsearch";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
const MAX_ARGS: Option<u32> = Some(3);
|
||||
@@ -137,12 +137,13 @@ impl PlaylistSearchResponseEntry {
|
||||
}
|
||||
|
||||
impl CommandResponse for PlaylistSearchResponse {
|
||||
type Request = PlaylistSearchRequest;
|
||||
|
||||
fn parse(_parts: ResponseAttributes<'_>) -> Result<Self, ResponseParserError> {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
impl Command for PlaylistSearch {
|
||||
type Request = PlaylistSearchRequest;
|
||||
type Response = PlaylistSearchResponse;
|
||||
fn serialize(&self) -> Vec<u8> {
|
||||
unimplemented!("response serialization is not yet implemented for PlaylistSearchResponse")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandRequest, CommandResponse, RequestParserError, ResponseParserError},
|
||||
commands::{CommandRequest, CommandResponse, RequestParserError, ResponseParserError},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
types::{DbSongInfo, PlaylistVersion, Priority, SongId, SongPosition, WindowRange},
|
||||
};
|
||||
|
||||
pub struct PlChanges;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct PlChangesRequest {
|
||||
pub version: PlaylistVersion,
|
||||
@@ -22,6 +20,8 @@ impl PlChangesRequest {
|
||||
}
|
||||
|
||||
impl CommandRequest for PlChangesRequest {
|
||||
type Response = PlChangesResponse;
|
||||
|
||||
const COMMAND: &'static str = "plchanges";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
const MAX_ARGS: Option<u32> = Some(2);
|
||||
@@ -95,12 +95,13 @@ impl PlChangesResponseEntry {
|
||||
}
|
||||
|
||||
impl CommandResponse for PlChangesResponse {
|
||||
type Request = PlChangesRequest;
|
||||
|
||||
fn parse(_parts: ResponseAttributes<'_>) -> Result<Self, ResponseParserError> {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
impl Command for PlChanges {
|
||||
type Request = PlChangesRequest;
|
||||
type Response = PlChangesResponse;
|
||||
fn serialize(&self) -> Vec<u8> {
|
||||
unimplemented!("response serialization is not yet implemented for PlChangesResponse")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandRequest, CommandResponse, RequestParserError, ResponseParserError},
|
||||
commands::{CommandRequest, CommandResponse, RequestParserError, ResponseParserError},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
types::{PlaylistVersion, SongId, SongPosition, WindowRange},
|
||||
};
|
||||
|
||||
pub struct PlChangesPosId;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct PlChangesPosIdRequest {
|
||||
pub version: PlaylistVersion,
|
||||
@@ -22,6 +20,8 @@ impl PlChangesPosIdRequest {
|
||||
}
|
||||
|
||||
impl CommandRequest for PlChangesPosIdRequest {
|
||||
type Response = PlChangesPosIdResponse;
|
||||
|
||||
const COMMAND: &'static str = "plchangesposid";
|
||||
const MIN_ARGS: u32 = 1;
|
||||
const MAX_ARGS: Option<u32> = Some(2);
|
||||
@@ -84,12 +84,13 @@ impl PlChangesPosIdResponseEntry {
|
||||
}
|
||||
|
||||
impl CommandResponse for PlChangesPosIdResponse {
|
||||
type Request = PlChangesPosIdRequest;
|
||||
|
||||
fn parse(_parts: ResponseAttributes<'_>) -> Result<Self, ResponseParserError> {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
impl Command for PlChangesPosId {
|
||||
type Request = PlChangesPosIdRequest;
|
||||
type Response = PlChangesPosIdResponse;
|
||||
fn serialize(&self) -> Vec<u8> {
|
||||
unimplemented!("response serialization is not yet implemented for PlChangesPosIdResponse")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandRequest, RequestParserError, empty_command_response},
|
||||
commands::{CommandRequest, RequestParserError, empty_command_response},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
types::{Priority, WindowRange},
|
||||
};
|
||||
|
||||
pub struct Prio;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct PrioRequest {
|
||||
pub prio: Priority,
|
||||
@@ -21,6 +19,8 @@ impl PrioRequest {
|
||||
}
|
||||
|
||||
impl CommandRequest for PrioRequest {
|
||||
type Response = PrioResponse;
|
||||
|
||||
const COMMAND: &'static str = "prio";
|
||||
const MIN_ARGS: u32 = 2;
|
||||
const MAX_ARGS: Option<u32> = Some(2);
|
||||
@@ -55,8 +55,3 @@ impl CommandRequest for PrioRequest {
|
||||
}
|
||||
|
||||
empty_command_response!(Prio);
|
||||
|
||||
impl Command for Prio {
|
||||
type Request = PrioRequest;
|
||||
type Response = PrioResponse;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user