From a89ad2f93e28c3233655e4f47274797e48b685f2 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Sat, 10 Jan 2026 00:12:15 +0900 Subject: [PATCH] commands: constructors for all commands --- src/commands/audio_output_devices/outputs.rs | 24 ++++++++ .../audio_output_devices/outputset.rs | 10 ++++ src/commands/client_to_client/channels.rs | 6 ++ src/commands/client_to_client/readmessages.rs | 12 ++++ src/commands/client_to_client/sendmessage.rs | 6 ++ .../connection_settings/protocol_disable.rs | 6 ++ .../connection_settings/protocol_enable.rs | 6 ++ .../connection_settings/tag_types_disable.rs | 6 ++ .../connection_settings/tag_types_enable.rs | 6 ++ .../connection_settings/tag_types_reset.rs | 6 ++ src/commands/controlling_playback/pause.rs | 6 ++ src/commands/controlling_playback/seek.rs | 6 ++ src/commands/controlling_playback/seekcur.rs | 6 ++ src/commands/controlling_playback/seekid.rs | 6 ++ .../mounts_and_neighbors/listneighbors.rs | 6 ++ src/commands/mounts_and_neighbors/mount.rs | 6 ++ src/commands/mounts_and_neighbors/unmount.rs | 6 ++ src/commands/music_database/albumart.rs | 12 ++++ src/commands/music_database/count.rs | 12 ++++ src/commands/music_database/find.rs | 16 ++++++ src/commands/music_database/findadd.rs | 16 ++++++ src/commands/music_database/getfingerprint.rs | 6 ++ src/commands/music_database/list.rs | 22 ++++++++ src/commands/music_database/listall.rs | 6 ++ src/commands/music_database/listallinfo.rs | 6 ++ src/commands/music_database/listfiles.rs | 6 ++ src/commands/music_database/lsinfo.rs | 6 ++ src/commands/music_database/readcomments.rs | 6 ++ src/commands/music_database/readpicture.rs | 16 ++++++ src/commands/music_database/rescan.rs | 6 ++ src/commands/music_database/search.rs | 16 ++++++ src/commands/music_database/searchadd.rs | 16 ++++++ src/commands/music_database/searchaddpl.rs | 18 ++++++ src/commands/music_database/searchcount.rs | 12 ++++ src/commands/music_database/update.rs | 6 ++ src/commands/playback_options/mixrampdelay.rs | 1 + src/commands/playback_options/random.rs | 6 ++ src/commands/playback_options/repeat.rs | 6 ++ .../playback_options/replay_gain_status.rs | 6 ++ .../querying_mpd_status/currentsong.rs | 16 ++++++ src/commands/querying_mpd_status/idle.rs | 6 ++ src/commands/querying_mpd_status/stats.rs | 22 ++++++++ src/commands/querying_mpd_status/status.rs | 56 +++++++++++++++++++ src/commands/queue/add.rs | 6 ++ src/commands/queue/addid.rs | 12 ++++ src/commands/queue/addtagid.rs | 10 ++++ src/commands/queue/cleartagid.rs | 6 ++ src/commands/queue/move_.rs | 6 ++ src/commands/queue/moveid.rs | 6 ++ src/commands/queue/playlist.rs | 6 ++ src/commands/queue/playlistfind.rs | 32 +++++++++++ src/commands/queue/playlistid.rs | 22 ++++++++ src/commands/queue/playlistinfo.rs | 22 ++++++++ src/commands/queue/playlistsearch.rs | 32 +++++++++++ src/commands/queue/plchanges.rs | 28 ++++++++++ src/commands/queue/plchangesposid.rs | 18 ++++++ src/commands/queue/prio.rs | 6 ++ src/commands/queue/prioid.rs | 6 ++ src/commands/queue/rangeid.rs | 9 +++ src/commands/queue/swap.rs | 6 ++ src/commands/queue/swapid.rs | 6 ++ src/commands/reflection/config.rs | 10 ++++ src/commands/reflection/decoders.rs | 16 ++++++ src/commands/stickers/sticker_dec.rs | 11 ++++ src/commands/stickers/sticker_delete.rs | 10 ++++ src/commands/stickers/sticker_find.rs | 30 ++++++++++ src/commands/stickers/sticker_get.rs | 10 ++++ src/commands/stickers/sticker_inc.rs | 11 ++++ src/commands/stickers/sticker_list.rs | 12 ++++ src/commands/stickers/sticker_set.rs | 11 ++++ src/commands/stickers/stickernamestypes.rs | 12 ++++ src/commands/stored_playlists/listplaylist.rs | 6 ++ .../stored_playlists/listplaylistinfo.rs | 12 ++++ .../stored_playlists/listplaylists.rs | 15 +++++ src/commands/stored_playlists/load.rs | 14 +++++ src/commands/stored_playlists/playlistadd.rs | 10 ++++ .../stored_playlists/playlistdelete.rs | 9 +++ .../stored_playlists/playlistlength.rs | 6 ++ src/commands/stored_playlists/playlistmove.rs | 10 ++++ src/commands/stored_playlists/rename.rs | 6 ++ src/commands/stored_playlists/save.rs | 9 +++ .../stored_playlists/searchplaylist.rs | 10 ++++ 82 files changed, 932 insertions(+) diff --git a/src/commands/audio_output_devices/outputs.rs b/src/commands/audio_output_devices/outputs.rs index a9c978a..94852f9 100644 --- a/src/commands/audio_output_devices/outputs.rs +++ b/src/commands/audio_output_devices/outputs.rs @@ -15,6 +15,12 @@ empty_command_request!(Outputs, "outputs"); #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct OutputsResponse(Vec); +impl OutputsResponse { + pub fn new(outputs: Vec) -> Self { + OutputsResponse(outputs) + } +} + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct Output { pub id: AudioOutputId, @@ -24,6 +30,24 @@ pub struct Output { pub attribute: HashMap, } +impl Output { + pub fn new( + id: AudioOutputId, + name: String, + plugin: String, + enabled: bool, + attribute: HashMap, + ) -> Self { + Output { + id, + name, + plugin, + enabled, + attribute, + } + } +} + impl CommandResponse for OutputsResponse { fn into_response_enum(self) -> crate::Response { todo!() diff --git a/src/commands/audio_output_devices/outputset.rs b/src/commands/audio_output_devices/outputset.rs index 7b7e850..c8353f3 100644 --- a/src/commands/audio_output_devices/outputset.rs +++ b/src/commands/audio_output_devices/outputset.rs @@ -15,6 +15,16 @@ pub struct OutputSetRequest { pub attribute_value: String, } +impl OutputSetRequest { + pub fn new(output_id: AudioOutputId, attribute_name: String, attribute_value: String) -> Self { + Self { + output_id, + attribute_name, + attribute_value, + } + } +} + impl CommandRequest for OutputSetRequest { const COMMAND: &'static str = "outputset"; const MIN_ARGS: u32 = 3; diff --git a/src/commands/client_to_client/channels.rs b/src/commands/client_to_client/channels.rs index 8ea1f15..d16303b 100644 --- a/src/commands/client_to_client/channels.rs +++ b/src/commands/client_to_client/channels.rs @@ -15,6 +15,12 @@ pub struct ChannelsResponse { pub channels: Vec, } +impl ChannelsResponse { + pub fn new(channels: Vec) -> Self { + ChannelsResponse { channels } + } +} + impl CommandResponse for ChannelsResponse { fn into_response_enum(self) -> crate::Response { todo!() diff --git a/src/commands/client_to_client/readmessages.rs b/src/commands/client_to_client/readmessages.rs index e1c115b..e705e29 100644 --- a/src/commands/client_to_client/readmessages.rs +++ b/src/commands/client_to_client/readmessages.rs @@ -13,12 +13,24 @@ empty_command_request!(ReadMessages, "readmessages"); #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct ReadMessagesResponse(Vec); +impl ReadMessagesResponse { + pub fn new(entries: Vec) -> Self { + ReadMessagesResponse(entries) + } +} + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct ReadMessagesResponseEntry { channel: ChannelName, message: String, } +impl ReadMessagesResponseEntry { + pub fn new(channel: ChannelName, message: String) -> Self { + ReadMessagesResponseEntry { channel, message } + } +} + impl CommandResponse for ReadMessagesResponse { fn into_response_enum(self) -> crate::Response { todo!() diff --git a/src/commands/client_to_client/sendmessage.rs b/src/commands/client_to_client/sendmessage.rs index 27af7a0..826854d 100644 --- a/src/commands/client_to_client/sendmessage.rs +++ b/src/commands/client_to_client/sendmessage.rs @@ -14,6 +14,12 @@ pub struct SendMessageRequest { pub message: String, } +impl SendMessageRequest { + pub fn new(channel: ChannelName, message: String) -> Self { + Self { channel, message } + } +} + impl CommandRequest for SendMessageRequest { const COMMAND: &'static str = "sendmessage"; const MIN_ARGS: u32 = 2; diff --git a/src/commands/connection_settings/protocol_disable.rs b/src/commands/connection_settings/protocol_disable.rs index a494e53..e77b570 100644 --- a/src/commands/connection_settings/protocol_disable.rs +++ b/src/commands/connection_settings/protocol_disable.rs @@ -8,6 +8,12 @@ pub struct ProtocolDisable; pub struct ProtocolDisableRequest(Vec); +impl ProtocolDisableRequest { + pub fn new(features: Vec) -> Self { + ProtocolDisableRequest(features) + } +} + impl CommandRequest for ProtocolDisableRequest { const COMMAND: &'static str = "protocol disable"; const MIN_ARGS: u32 = 1; diff --git a/src/commands/connection_settings/protocol_enable.rs b/src/commands/connection_settings/protocol_enable.rs index a17ef58..01ecb59 100644 --- a/src/commands/connection_settings/protocol_enable.rs +++ b/src/commands/connection_settings/protocol_enable.rs @@ -8,6 +8,12 @@ pub struct ProtocolEnable; pub struct ProtocolEnableRequest(Vec); +impl ProtocolEnableRequest { + pub fn new(features: Vec) -> Self { + ProtocolEnableRequest(features) + } +} + impl CommandRequest for ProtocolEnableRequest { const COMMAND: &'static str = "protocol enable"; const MIN_ARGS: u32 = 1; diff --git a/src/commands/connection_settings/tag_types_disable.rs b/src/commands/connection_settings/tag_types_disable.rs index 6575910..132f4d0 100644 --- a/src/commands/connection_settings/tag_types_disable.rs +++ b/src/commands/connection_settings/tag_types_disable.rs @@ -10,6 +10,12 @@ pub struct TagTypesDisable; pub struct TagTypesDisableRequest(Vec); +impl TagTypesDisableRequest { + pub fn new(tag_types: Vec) -> Self { + TagTypesDisableRequest(tag_types) + } +} + impl CommandRequest for TagTypesDisableRequest { const COMMAND: &'static str = "tagtypes disable"; const MIN_ARGS: u32 = 1; diff --git a/src/commands/connection_settings/tag_types_enable.rs b/src/commands/connection_settings/tag_types_enable.rs index 382b29c..f901325 100644 --- a/src/commands/connection_settings/tag_types_enable.rs +++ b/src/commands/connection_settings/tag_types_enable.rs @@ -8,6 +8,12 @@ pub struct TagTypesEnable; pub struct TagTypesEnableRequest(Vec); +impl TagTypesEnableRequest { + pub fn new(tag_types: Vec) -> Self { + TagTypesEnableRequest(tag_types) + } +} + impl CommandRequest for TagTypesEnableRequest { const COMMAND: &'static str = "tagtypes enable"; const MIN_ARGS: u32 = 1; diff --git a/src/commands/connection_settings/tag_types_reset.rs b/src/commands/connection_settings/tag_types_reset.rs index 39abca8..1d95211 100644 --- a/src/commands/connection_settings/tag_types_reset.rs +++ b/src/commands/connection_settings/tag_types_reset.rs @@ -8,6 +8,12 @@ pub struct TagTypesReset; pub struct TagTypesResetRequest(Vec); +impl TagTypesResetRequest { + pub fn new(tag_types: Vec) -> Self { + TagTypesResetRequest(tag_types) + } +} + impl CommandRequest for TagTypesResetRequest { const COMMAND: &'static str = "tagtypes reset"; const MIN_ARGS: u32 = 1; diff --git a/src/commands/controlling_playback/pause.rs b/src/commands/controlling_playback/pause.rs index 1025aa3..da0cb8b 100644 --- a/src/commands/controlling_playback/pause.rs +++ b/src/commands/controlling_playback/pause.rs @@ -7,6 +7,12 @@ pub struct Pause; pub struct PauseRequest(Option); +impl PauseRequest { + pub fn new(state: Option) -> Self { + PauseRequest(state) + } +} + impl CommandRequest for PauseRequest { const COMMAND: &'static str = "pause"; const MIN_ARGS: u32 = 0; diff --git a/src/commands/controlling_playback/seek.rs b/src/commands/controlling_playback/seek.rs index f4cc2f5..c46f789 100644 --- a/src/commands/controlling_playback/seek.rs +++ b/src/commands/controlling_playback/seek.rs @@ -14,6 +14,12 @@ pub struct SeekRequest { pub time: TimeWithFractions, } +impl SeekRequest { + pub fn new(songpos: SongPosition, time: TimeWithFractions) -> Self { + Self { songpos, time } + } +} + impl CommandRequest for SeekRequest { const COMMAND: &'static str = "seek"; const MIN_ARGS: u32 = 2; diff --git a/src/commands/controlling_playback/seekcur.rs b/src/commands/controlling_playback/seekcur.rs index 4b166e8..82e19b1 100644 --- a/src/commands/controlling_playback/seekcur.rs +++ b/src/commands/controlling_playback/seekcur.rs @@ -14,6 +14,12 @@ pub struct SeekCurRequest { pub time: TimeWithFractions, } +impl SeekCurRequest { + pub fn new(mode: SeekMode, time: TimeWithFractions) -> Self { + Self { mode, time } + } +} + impl CommandRequest for SeekCurRequest { const COMMAND: &'static str = "seekcur"; const MIN_ARGS: u32 = 1; diff --git a/src/commands/controlling_playback/seekid.rs b/src/commands/controlling_playback/seekid.rs index ea87cb4..16b1dc6 100644 --- a/src/commands/controlling_playback/seekid.rs +++ b/src/commands/controlling_playback/seekid.rs @@ -14,6 +14,12 @@ pub struct SeekIdRequest { pub time: TimeWithFractions, } +impl SeekIdRequest { + pub fn new(songid: SongId, time: TimeWithFractions) -> Self { + Self { songid, time } + } +} + impl CommandRequest for SeekIdRequest { const COMMAND: &'static str = "seekid"; const MIN_ARGS: u32 = 2; diff --git a/src/commands/mounts_and_neighbors/listneighbors.rs b/src/commands/mounts_and_neighbors/listneighbors.rs index 606b193..8f12812 100644 --- a/src/commands/mounts_and_neighbors/listneighbors.rs +++ b/src/commands/mounts_and_neighbors/listneighbors.rs @@ -14,6 +14,12 @@ empty_command_request!(ListNeighbors, "listneighbors"); #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct ListNeighborsResponse(HashMap); +impl ListNeighborsResponse { + pub fn new(map: HashMap) -> Self { + ListNeighborsResponse(map) + } +} + impl CommandResponse for ListNeighborsResponse { fn into_response_enum(self) -> crate::Response { todo!() diff --git a/src/commands/mounts_and_neighbors/mount.rs b/src/commands/mounts_and_neighbors/mount.rs index 5300f12..11a4faa 100644 --- a/src/commands/mounts_and_neighbors/mount.rs +++ b/src/commands/mounts_and_neighbors/mount.rs @@ -14,6 +14,12 @@ pub struct MountRequest { pub uri: Uri, } +impl MountRequest { + pub fn new(path: MountPath, uri: Uri) -> Self { + MountRequest { path, uri } + } +} + impl CommandRequest for MountRequest { const COMMAND: &'static str = "mount"; const MIN_ARGS: u32 = 2; diff --git a/src/commands/mounts_and_neighbors/unmount.rs b/src/commands/mounts_and_neighbors/unmount.rs index e442c1d..df5ac3a 100644 --- a/src/commands/mounts_and_neighbors/unmount.rs +++ b/src/commands/mounts_and_neighbors/unmount.rs @@ -10,6 +10,12 @@ pub struct Unmount; #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] pub struct UnmountRequest(MountPath); +impl UnmountRequest { + pub fn new(path: MountPath) -> Self { + UnmountRequest(path) + } +} + impl CommandRequest for UnmountRequest { const COMMAND: &'static str = "unmount"; const MIN_ARGS: u32 = 1; diff --git a/src/commands/music_database/albumart.rs b/src/commands/music_database/albumart.rs index fcb59b7..a9d93c5 100644 --- a/src/commands/music_database/albumart.rs +++ b/src/commands/music_database/albumart.rs @@ -17,6 +17,12 @@ pub struct AlbumArtRequest { offset: Offset, } +impl AlbumArtRequest { + pub fn new(uri: Uri, offset: Offset) -> Self { + AlbumArtRequest { uri, offset } + } +} + impl CommandRequest for AlbumArtRequest { const COMMAND: &'static str = "albumart"; const MIN_ARGS: u32 = 2; @@ -69,6 +75,12 @@ pub struct AlbumArtResponse { pub binary: Vec, } +impl AlbumArtResponse { + pub fn new(size: usize, binary: Vec) -> Self { + AlbumArtResponse { size, binary } + } +} + impl CommandResponse for AlbumArtResponse { fn into_response_enum(self) -> crate::Response { todo!() diff --git a/src/commands/music_database/count.rs b/src/commands/music_database/count.rs index 0496cf3..d79d765 100644 --- a/src/commands/music_database/count.rs +++ b/src/commands/music_database/count.rs @@ -18,6 +18,12 @@ pub struct CountRequest { group: Option, } +impl CountRequest { + pub fn new(filter: Filter, group: Option) -> Self { + CountRequest { filter, group } + } +} + impl CommandRequest for CountRequest { const COMMAND: &'static str = "count"; const MIN_ARGS: u32 = 1; @@ -84,6 +90,12 @@ pub struct CountResponse { pub playtime: u64, } +impl CountResponse { + pub fn new(songs: usize, playtime: u64) -> Self { + CountResponse { songs, playtime } + } +} + impl CommandResponse for CountResponse { fn into_response_enum(self) -> crate::Response { todo!() diff --git a/src/commands/music_database/find.rs b/src/commands/music_database/find.rs index cc904e1..ff1972a 100644 --- a/src/commands/music_database/find.rs +++ b/src/commands/music_database/find.rs @@ -17,6 +17,16 @@ pub struct FindRequest { window: Option, } +impl FindRequest { + pub fn new(filter: Filter, sort: Option, window: Option) -> Self { + Self { + filter, + sort, + window, + } + } +} + impl CommandRequest for FindRequest { const COMMAND: &'static str = "find"; const MIN_ARGS: u32 = 1; @@ -111,6 +121,12 @@ impl CommandRequest for FindRequest { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct FindResponse(Vec); +impl FindResponse { + pub fn new(items: Vec) -> Self { + FindResponse(items) + } +} + impl CommandResponse for FindResponse { fn into_response_enum(self) -> crate::Response { todo!() diff --git a/src/commands/music_database/findadd.rs b/src/commands/music_database/findadd.rs index 6c1a0e1..bfdfcb5 100644 --- a/src/commands/music_database/findadd.rs +++ b/src/commands/music_database/findadd.rs @@ -17,6 +17,22 @@ pub struct FindAddRequest { position: Option, } +impl FindAddRequest { + pub fn new( + filter: Filter, + sort: Option, + window: Option, + position: Option, + ) -> Self { + Self { + filter, + sort, + window, + position, + } + } +} + impl CommandRequest for FindAddRequest { const COMMAND: &'static str = "findadd"; const MIN_ARGS: u32 = 1; diff --git a/src/commands/music_database/getfingerprint.rs b/src/commands/music_database/getfingerprint.rs index 7b0fb58..bd1e2fb 100644 --- a/src/commands/music_database/getfingerprint.rs +++ b/src/commands/music_database/getfingerprint.rs @@ -17,6 +17,12 @@ pub struct GetFingerprintResponse { pub chromaprint: String, } +impl GetFingerprintResponse { + pub fn new(chromaprint: String) -> Self { + Self { chromaprint } + } +} + impl CommandResponse for GetFingerprintResponse { fn into_response_enum(self) -> crate::Response { todo!() diff --git a/src/commands/music_database/list.rs b/src/commands/music_database/list.rs index 1b99fad..d6e85b7 100644 --- a/src/commands/music_database/list.rs +++ b/src/commands/music_database/list.rs @@ -18,6 +18,22 @@ pub struct ListRequest { window: Option, } +impl ListRequest { + pub fn new( + tagname: TagName, + filter: Option, + groups: Vec, + window: Option, + ) -> Self { + Self { + tagname, + filter, + groups, + window, + } + } +} + impl CommandRequest for ListRequest { const COMMAND: &'static str = "list"; const MIN_ARGS: u32 = 1; @@ -138,6 +154,12 @@ impl CommandRequest for ListRequest { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct ListResponse(Vec); +impl ListResponse { + pub fn new(items: Vec) -> Self { + ListResponse(items) + } +} + impl CommandResponse for ListResponse { fn into_response_enum(self) -> crate::Response { todo!() diff --git a/src/commands/music_database/listall.rs b/src/commands/music_database/listall.rs index 23e2547..813cf99 100644 --- a/src/commands/music_database/listall.rs +++ b/src/commands/music_database/listall.rs @@ -16,6 +16,12 @@ single_optional_item_command_request!(ListAll, "listall", Uri); #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct ListAllResponse(Vec); +impl ListAllResponse { + pub fn new(items: Vec) -> Self { + ListAllResponse(items) + } +} + impl CommandResponse for ListAllResponse { fn into_response_enum(self) -> crate::Response { todo!() diff --git a/src/commands/music_database/listallinfo.rs b/src/commands/music_database/listallinfo.rs index 66760ae..72fa1b9 100644 --- a/src/commands/music_database/listallinfo.rs +++ b/src/commands/music_database/listallinfo.rs @@ -16,6 +16,12 @@ single_optional_item_command_request!(ListAllInfo, "listallinfo", Uri); #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct ListAllInfoResponse(Vec); +impl ListAllInfoResponse { + pub fn new(items: Vec) -> Self { + ListAllInfoResponse(items) + } +} + impl CommandResponse for ListAllInfoResponse { fn from_response_enum(response: crate::Response) -> Option { todo!() diff --git a/src/commands/music_database/listfiles.rs b/src/commands/music_database/listfiles.rs index 90cbd1d..4c5c25b 100644 --- a/src/commands/music_database/listfiles.rs +++ b/src/commands/music_database/listfiles.rs @@ -15,6 +15,12 @@ single_optional_item_command_request!(ListFiles, "listfiles", Uri); #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct ListFilesResponse(Vec); +impl ListFilesResponse { + pub fn new(items: Vec) -> Self { + ListFilesResponse(items) + } +} + impl CommandResponse for ListFilesResponse { fn into_response_enum(self) -> crate::Response { todo!() diff --git a/src/commands/music_database/lsinfo.rs b/src/commands/music_database/lsinfo.rs index 65a9c09..587ca68 100644 --- a/src/commands/music_database/lsinfo.rs +++ b/src/commands/music_database/lsinfo.rs @@ -15,6 +15,12 @@ single_optional_item_command_request!(LsInfo, "lsinfo", Uri); #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct LsInfoResponse(Vec); +impl LsInfoResponse { + pub fn new(items: Vec) -> Self { + LsInfoResponse(items) + } +} + impl CommandResponse for LsInfoResponse { fn into_response_enum(self) -> crate::Response { todo!() diff --git a/src/commands/music_database/readcomments.rs b/src/commands/music_database/readcomments.rs index 268cf68..11e1d63 100644 --- a/src/commands/music_database/readcomments.rs +++ b/src/commands/music_database/readcomments.rs @@ -15,6 +15,12 @@ single_item_command_request!(ReadComments, "readcomments", Uri); #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct ReadCommentsResponse(HashMap); +impl ReadCommentsResponse { + pub fn new(comments: HashMap) -> Self { + ReadCommentsResponse(comments) + } +} + impl CommandResponse for ReadCommentsResponse { fn into_response_enum(self) -> crate::Response { todo!() diff --git a/src/commands/music_database/readpicture.rs b/src/commands/music_database/readpicture.rs index 8573921..ece25fa 100644 --- a/src/commands/music_database/readpicture.rs +++ b/src/commands/music_database/readpicture.rs @@ -19,6 +19,12 @@ pub struct ReadPictureRequest { pub offset: Offset, } +impl ReadPictureRequest { + pub fn new(uri: Uri, offset: Offset) -> Self { + Self { uri, offset } + } +} + impl CommandRequest for ReadPictureRequest { const COMMAND: &'static str = "readpicture"; const MIN_ARGS: u32 = 2; @@ -72,6 +78,16 @@ pub struct ReadPictureResponse { pub mimetype: Option, } +impl ReadPictureResponse { + pub fn new(size: usize, binary: Vec, mimetype: Option) -> Self { + Self { + size, + binary, + mimetype, + } + } +} + impl CommandResponse for ReadPictureResponse { fn into_response_enum(self) -> crate::Response { todo!() diff --git a/src/commands/music_database/rescan.rs b/src/commands/music_database/rescan.rs index ae3c04f..11266ea 100644 --- a/src/commands/music_database/rescan.rs +++ b/src/commands/music_database/rescan.rs @@ -19,6 +19,12 @@ pub struct RescanResponse { pub updating_db: usize, } +impl RescanResponse { + pub fn new(updating_db: usize) -> Self { + RescanResponse { updating_db } + } +} + impl CommandResponse for RescanResponse { fn into_response_enum(self) -> crate::Response { todo!() diff --git a/src/commands/music_database/search.rs b/src/commands/music_database/search.rs index 5f7f131..b727a40 100644 --- a/src/commands/music_database/search.rs +++ b/src/commands/music_database/search.rs @@ -17,6 +17,16 @@ pub struct SearchRequest { window: Option, } +impl SearchRequest { + pub fn new(filter: Filter, sort: Option, window: Option) -> Self { + Self { + filter, + sort, + window, + } + } +} + impl CommandRequest for SearchRequest { const COMMAND: &'static str = "search"; const MIN_ARGS: u32 = 1; @@ -111,6 +121,12 @@ impl CommandRequest for SearchRequest { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct SearchResponse(Vec); +impl SearchResponse { + pub fn new(items: Vec) -> Self { + SearchResponse(items) + } +} + impl CommandResponse for SearchResponse { fn from_response_enum(response: crate::Response) -> Option { todo!() diff --git a/src/commands/music_database/searchadd.rs b/src/commands/music_database/searchadd.rs index 1855bd5..d715d2e 100644 --- a/src/commands/music_database/searchadd.rs +++ b/src/commands/music_database/searchadd.rs @@ -17,6 +17,22 @@ pub struct SearchAddRequest { position: Option, } +impl SearchAddRequest { + pub fn new( + filter: Filter, + sort: Option, + window: Option, + position: Option, + ) -> Self { + Self { + filter, + sort, + window, + position, + } + } +} + impl CommandRequest for SearchAddRequest { const COMMAND: &'static str = "searchadd"; const MIN_ARGS: u32 = 1; diff --git a/src/commands/music_database/searchaddpl.rs b/src/commands/music_database/searchaddpl.rs index 619128b..15ab249 100644 --- a/src/commands/music_database/searchaddpl.rs +++ b/src/commands/music_database/searchaddpl.rs @@ -18,6 +18,24 @@ pub struct SearchAddPlRequest { position: Option, } +impl SearchAddPlRequest { + pub fn new( + playlist_name: PlaylistName, + filter: Filter, + sort: Option, + window: Option, + position: Option, + ) -> Self { + Self { + playlist_name, + filter, + sort, + window, + position, + } + } +} + impl CommandRequest for SearchAddPlRequest { const COMMAND: &'static str = "searchaddpl"; const MIN_ARGS: u32 = 2; diff --git a/src/commands/music_database/searchcount.rs b/src/commands/music_database/searchcount.rs index 3513638..8967f02 100644 --- a/src/commands/music_database/searchcount.rs +++ b/src/commands/music_database/searchcount.rs @@ -18,6 +18,12 @@ pub struct SearchCountRequest { group: Option, } +impl SearchCountRequest { + pub fn new(filter: Filter, group: Option) -> Self { + Self { filter, group } + } +} + impl CommandRequest for SearchCountRequest { const COMMAND: &'static str = "searchcount"; const MIN_ARGS: u32 = 1; @@ -85,6 +91,12 @@ pub struct SearchCountResponse { pub playtime: Seconds, } +impl SearchCountResponse { + pub fn new(songs: usize, playtime: Seconds) -> Self { + Self { songs, playtime } + } +} + impl CommandResponse for SearchCountResponse { fn from_response_enum(response: crate::Response) -> Option { todo!() diff --git a/src/commands/music_database/update.rs b/src/commands/music_database/update.rs index d4833cc..44b8594 100644 --- a/src/commands/music_database/update.rs +++ b/src/commands/music_database/update.rs @@ -19,6 +19,12 @@ pub struct UpdateResponse { updating_db: usize, } +impl UpdateResponse { + pub fn new(updating_db: usize) -> Self { + UpdateResponse { updating_db } + } +} + impl CommandResponse for UpdateResponse { fn into_response_enum(self) -> crate::Response { todo!() diff --git a/src/commands/playback_options/mixrampdelay.rs b/src/commands/playback_options/mixrampdelay.rs index 95f7778..f165272 100644 --- a/src/commands/playback_options/mixrampdelay.rs +++ b/src/commands/playback_options/mixrampdelay.rs @@ -6,6 +6,7 @@ use crate::{ pub struct MixRampDelay; single_item_command_request!(MixRampDelay, "mixrampdelay", Seconds); + empty_command_response!(MixRampDelay); impl Command for MixRampDelay { diff --git a/src/commands/playback_options/random.rs b/src/commands/playback_options/random.rs index ae8cd8a..00a2c6b 100644 --- a/src/commands/playback_options/random.rs +++ b/src/commands/playback_options/random.rs @@ -7,6 +7,12 @@ pub struct Random; pub struct RandomRequest(bool); +impl RandomRequest { + pub fn new(state: bool) -> Self { + Self(state) + } +} + impl CommandRequest for RandomRequest { const COMMAND: &'static str = "random"; const MIN_ARGS: u32 = 1; diff --git a/src/commands/playback_options/repeat.rs b/src/commands/playback_options/repeat.rs index 9f64ea1..e606b8e 100644 --- a/src/commands/playback_options/repeat.rs +++ b/src/commands/playback_options/repeat.rs @@ -7,6 +7,12 @@ pub struct Repeat; pub struct RepeatRequest(bool); +impl RepeatRequest { + pub fn new(state: bool) -> Self { + RepeatRequest(state) + } +} + impl CommandRequest for RepeatRequest { const COMMAND: &'static str = "repeat"; const MIN_ARGS: u32 = 1; diff --git a/src/commands/playback_options/replay_gain_status.rs b/src/commands/playback_options/replay_gain_status.rs index 01b987a..7797caa 100644 --- a/src/commands/playback_options/replay_gain_status.rs +++ b/src/commands/playback_options/replay_gain_status.rs @@ -17,6 +17,12 @@ pub struct ReplayGainStatusResponse { pub replay_gain_mode: ReplayGainModeMode, } +impl ReplayGainStatusResponse { + pub fn new(replay_gain_mode: ReplayGainModeMode) -> Self { + Self { replay_gain_mode } + } +} + impl CommandResponse for ReplayGainStatusResponse { fn into_response_enum(self) -> crate::Response { todo!() diff --git a/src/commands/querying_mpd_status/currentsong.rs b/src/commands/querying_mpd_status/currentsong.rs index 3cdf108..1b9d64f 100644 --- a/src/commands/querying_mpd_status/currentsong.rs +++ b/src/commands/querying_mpd_status/currentsong.rs @@ -23,6 +23,22 @@ pub struct CurrentSongResponse { song_info: DbSongInfo, } +impl CurrentSongResponse { + pub fn new( + position: SongPosition, + id: SongId, + priority: Option, + song_info: DbSongInfo, + ) -> Self { + Self { + position, + id, + priority, + song_info, + } + } +} + impl CommandResponse for CurrentSongResponse { fn into_response_enum(self) -> crate::Response { todo!() diff --git a/src/commands/querying_mpd_status/idle.rs b/src/commands/querying_mpd_status/idle.rs index b982848..cf40342 100644 --- a/src/commands/querying_mpd_status/idle.rs +++ b/src/commands/querying_mpd_status/idle.rs @@ -10,6 +10,12 @@ pub struct Idle; pub struct IdleRequest(Option>); +impl IdleRequest { + pub fn new(subsystems: Option>) -> Self { + IdleRequest(subsystems) + } +} + impl CommandRequest for IdleRequest { const COMMAND: &'static str = "idle"; const MIN_ARGS: u32 = 0; diff --git a/src/commands/querying_mpd_status/stats.rs b/src/commands/querying_mpd_status/stats.rs index 206fbd3..0218f71 100644 --- a/src/commands/querying_mpd_status/stats.rs +++ b/src/commands/querying_mpd_status/stats.rs @@ -24,6 +24,28 @@ pub struct StatsResponse { pub db_update: Option, } +impl StatsResponse { + pub fn new( + uptime: u64, + playtime: u64, + artists: Option, + albums: Option, + songs: Option, + db_playtime: Option, + db_update: Option, + ) -> Self { + Self { + uptime, + playtime, + artists, + albums, + songs, + db_playtime, + db_update, + } + } +} + impl CommandResponse for StatsResponse { fn into_response_enum(self) -> crate::Response { todo!() diff --git a/src/commands/querying_mpd_status/status.rs b/src/commands/querying_mpd_status/status.rs index 993c350..5ad7b11 100644 --- a/src/commands/querying_mpd_status/status.rs +++ b/src/commands/querying_mpd_status/status.rs @@ -65,6 +65,62 @@ pub struct StatusResponse { pub last_loaded_playlist: Option, } +impl StatusResponse { + pub fn new( + partition: String, + volume: Option, + repeat: bool, + random: bool, + single: BoolOrOneshot, + consume: BoolOrOneshot, + playlist: u32, + playlist_length: u64, + state: StatusResponseState, + song: Option, + song_id: Option, + next_song: Option, + next_song_id: Option, + time: Option<(u64, u64)>, + elapsed: Option, + duration: Option, + bitrate: Option, + xfade: Option, + mixrampdb: Option, + mixrampdelay: Option, + audio: Option