commands: add response types for multiple commands
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
Uri,
|
||||
commands::{Command, CommandResponse, ResponseParserError, empty_command_request},
|
||||
response_tokenizer::ResponseAttributes,
|
||||
};
|
||||
@@ -7,7 +10,8 @@ pub struct Playlist;
|
||||
|
||||
empty_command_request!(Playlist, "playlist");
|
||||
|
||||
pub struct PlaylistResponse();
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct PlaylistResponse(Vec<Uri>);
|
||||
|
||||
impl CommandResponse<'_> for PlaylistResponse {
|
||||
fn into_response_enum(self) -> crate::Response {
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, CommandRequest, RequestParserError, empty_command_response},
|
||||
DbSongInfo, Priority, Response, SongId, SongPosition,
|
||||
commands::{Command, CommandRequest, CommandResponse, RequestParserError, ResponseParserError},
|
||||
common::types::{Sort, WindowRange},
|
||||
filter::Filter,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
};
|
||||
|
||||
pub struct PlaylistFind;
|
||||
@@ -83,7 +85,30 @@ impl CommandRequest<'_> for PlaylistFindRequest {
|
||||
}
|
||||
}
|
||||
|
||||
empty_command_response!(PlaylistFind);
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct PlaylistFindResponse(Vec<PlaylistFindResponseEntry>);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct PlaylistFindResponseEntry {
|
||||
pub position: SongPosition,
|
||||
pub id: SongId,
|
||||
pub priority: Option<Priority>,
|
||||
pub song_info: DbSongInfo,
|
||||
}
|
||||
|
||||
impl CommandResponse<'_> for PlaylistFindResponse {
|
||||
fn into_response_enum(self) -> Response {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn from_response_enum(response: Response) -> Option<Self> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn parse(_parts: ResponseAttributes<'_>) -> Result<Self, ResponseParserError<'_>> {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
impl Command<'_, '_> for PlaylistFind {
|
||||
type Request = PlaylistFindRequest;
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
DbSongInfo, Priority, SongPosition,
|
||||
commands::{Command, CommandResponse, ResponseParserError, single_item_command_request},
|
||||
common::types::SongId,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -8,7 +11,16 @@ pub struct PlaylistId;
|
||||
|
||||
single_item_command_request!(PlaylistId, "playlistid", SongId);
|
||||
|
||||
pub struct PlaylistIdResponse();
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct PlaylistIdResponse(Vec<PlaylistIdResponseEntry>);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct PlaylistIdResponseEntry {
|
||||
pub position: SongPosition,
|
||||
pub id: SongId,
|
||||
pub priority: Option<Priority>,
|
||||
pub song_info: DbSongInfo,
|
||||
}
|
||||
|
||||
impl CommandResponse<'_> for PlaylistIdResponse {
|
||||
fn into_response_enum(self) -> crate::Response {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
DbSongInfo, Priority, SongId, SongPosition,
|
||||
commands::{
|
||||
Command, CommandResponse, RequestParserError, ResponseParserError,
|
||||
single_optional_item_command_request,
|
||||
@@ -14,7 +15,15 @@ pub struct PlaylistInfo;
|
||||
single_optional_item_command_request!(PlaylistInfo, "playlistinfo", OneOrRange);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct PlaylistInfoResponse;
|
||||
pub struct PlaylistInfoResponse(Vec<PlaylistInfoResponseEntry>);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct PlaylistInfoResponseEntry {
|
||||
pub position: SongPosition,
|
||||
pub id: SongId,
|
||||
pub priority: Option<Priority>,
|
||||
pub song_info: DbSongInfo,
|
||||
}
|
||||
|
||||
impl CommandResponse<'_> for PlaylistInfoResponse {
|
||||
fn into_response_enum(self) -> crate::Response {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
DbSongInfo, Priority, SongId, SongPosition,
|
||||
commands::{Command, CommandRequest, CommandResponse, RequestParserError, ResponseParserError},
|
||||
common::types::{Sort, WindowRange},
|
||||
filter::Filter,
|
||||
@@ -85,7 +86,15 @@ impl CommandRequest<'_> for PlaylistSearchRequest {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct PlaylistSearchResponse;
|
||||
pub struct PlaylistSearchResponse(Vec<PlaylistSearchResponseEntry>);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct PlaylistSearchResponseEntry {
|
||||
pub position: SongPosition,
|
||||
pub id: SongId,
|
||||
pub priority: Option<Priority>,
|
||||
pub song_info: DbSongInfo,
|
||||
}
|
||||
|
||||
impl CommandResponse<'_> for PlaylistSearchResponse {
|
||||
fn from_response_enum(response: crate::Response) -> Option<Self> {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
DbSongInfo, Priority, SongId, SongPosition,
|
||||
commands::{Command, CommandRequest, CommandResponse, RequestParserError, ResponseParserError},
|
||||
common::types::{PlaylistVersion, WindowRange},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
@@ -59,7 +60,15 @@ impl CommandRequest<'_> for PlChangesRequest {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct PlChangesResponse;
|
||||
pub struct PlChangesResponse(Vec<PlChangesResponseEntry>);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct PlChangesResponseEntry {
|
||||
pub position: SongPosition,
|
||||
pub id: SongId,
|
||||
pub priority: Option<Priority>,
|
||||
pub song_info: DbSongInfo,
|
||||
}
|
||||
|
||||
impl CommandResponse<'_> for PlChangesResponse {
|
||||
fn from_response_enum(response: crate::Response) -> Option<Self> {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
SongId, SongPosition,
|
||||
commands::{Command, CommandRequest, CommandResponse, RequestParserError, ResponseParserError},
|
||||
common::types::{PlaylistVersion, WindowRange},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
@@ -59,7 +60,14 @@ impl CommandRequest<'_> for PlChangesPosIdRequest {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct PlChangesPosIdResponse;
|
||||
pub struct PlChangesPosIdResponse(Vec<PlChangesPosIdResponseEntry>);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct PlChangesPosIdResponseEntry {
|
||||
// 'cpos'
|
||||
pub position: SongPosition,
|
||||
pub id: SongId,
|
||||
}
|
||||
|
||||
impl CommandResponse<'_> for PlChangesPosIdResponse {
|
||||
fn from_response_enum(response: crate::Response) -> Option<Self> {
|
||||
|
||||
Reference in New Issue
Block a user