diff --git a/src/commands.rs b/src/commands.rs index 9c31459..e34af14 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -272,6 +272,12 @@ macro_rules! empty_command_request { pub struct [<$name Request>]; } + impl paste::paste! { [<$name Request>] } { + pub fn new() -> Self { + Self + } + } + impl crate::commands::CommandRequest for paste::paste! { [<$name Request>] } { const COMMAND: &'static str = $command_name; const MIN_ARGS: u32 = 0; @@ -315,6 +321,12 @@ macro_rules! empty_command_response { pub struct [<$name Response>]; } + impl paste::paste! { [<$name Response>] } { + pub fn new() -> Self { + Self + } + } + impl crate::commands::CommandResponse for paste::paste! { [<$name Response>] } { fn into_response_enum(self) -> crate::Response { todo!() @@ -341,6 +353,12 @@ macro_rules! single_item_command_request { pub struct [<$name Request>] ($item_type); } + impl paste::paste! { [<$name Request>] } { + pub fn new(arg: $item_type) -> Self { + Self(arg) + } + } + impl crate::commands::CommandRequest for paste::paste! { [<$name Request>] } { const COMMAND: &'static str = $command_name; const MIN_ARGS: u32 = 1; @@ -394,6 +412,12 @@ macro_rules! single_optional_item_command_request { pub struct [<$name Request>] (Option<$item_type>); } + impl paste::paste! { [<$name Request>] } { + pub fn new(arg: Option<$item_type>) -> Self { + Self(arg) + } + } + impl crate::commands::CommandRequest for paste::paste! { [<$name Request>] } { const COMMAND: &'static str = $command_name; const MIN_ARGS: u32 = 0; @@ -453,6 +477,12 @@ macro_rules! single_item_command_response { pub struct [<$name Response>] ( $item_type ); } + impl paste::paste! { [<$name Response>] } { + pub fn new(arg: $item_type) -> Self { + Self(arg) + } + } + impl crate::commands::CommandResponse for paste::paste! { [<$name Response>] } { fn into_response_enum(self) -> crate::Response { todo!() @@ -497,6 +527,12 @@ macro_rules! multi_item_command_response { pub struct [<$name Response>] ( Vec<$item_type> ); } + impl paste::paste! { [<$name Response>] } { + pub fn new(arg: Vec<$item_type>) -> Self { + Self(arg) + } + } + impl crate::commands::CommandResponse for paste::paste! { [<$name Response>] } { 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..d8a0dd4 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 { + 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/sendmessage.rs b/src/commands/client_to_client/sendmessage.rs index 27af7a0..38bd93a 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 { + 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..cee6556 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 { + fn new(features: Vec) -> Self { + Self(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..d927913 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 { + fn new(features: Vec) -> Self { + Self(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..4fd4b21 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 { + fn new(tagnames: Vec) -> Self { + Self(tagnames) + } +} + 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..143aaa7 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 { + fn new(tagnames: Vec) -> Self { + Self(tagnames) + } +} + 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..30a4aed 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 { + fn new(tagnames: Vec) -> Self { + Self(tagnames) + } +} + 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..15bd22d 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 { + fn new(toggle: Option) -> Self { + Self(toggle) + } +} + impl CommandRequest for PauseRequest { const COMMAND: &'static str = "pause"; const MIN_ARGS: u32 = 0;