From 689138b282c6aa283b8d97d6497f31bcf196bf2b Mon Sep 17 00:00:00 2001 From: Baud Date: Sat, 16 Mar 2024 17:14:31 +0000 Subject: [PATCH] chore: Begone &Box --- .../src/atem_lib/atem_socket.rs | 2 +- .../src/commands/command_base.rs | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/atem-connection-rs/src/atem_lib/atem_socket.rs b/atem-connection-rs/src/atem_lib/atem_socket.rs index 554aa04..3653852 100644 --- a/atem-connection-rs/src/atem_lib/atem_socket.rs +++ b/atem-connection-rs/src/atem_lib/atem_socket.rs @@ -82,7 +82,7 @@ pub struct AtemSocketCommand { } impl AtemSocketCommand { - pub fn new(command: &Box, version: &ProtocolVersion) -> Self { + pub fn new(command: &C, version: &ProtocolVersion) -> Self { Self { payload: command.payload(version), raw_name: command.get_raw_name().to_string(), diff --git a/atem-connection-rs/src/commands/command_base.rs b/atem-connection-rs/src/commands/command_base.rs index 80001e3..edcfc38 100644 --- a/atem-connection-rs/src/commands/command_base.rs +++ b/atem-connection-rs/src/commands/command_base.rs @@ -15,11 +15,43 @@ pub trait SerializableCommand { fn payload(&self, version: &ProtocolVersion) -> Vec; } +impl SerializableCommand for Box { + fn payload(&self, version: &ProtocolVersion) -> Vec { + (**self).payload(version) + } +} + +impl SerializableCommand for &'_ Box { + fn payload(&self, version: &ProtocolVersion) -> Vec { + (**self).payload(version) + } +} + pub trait BasicWritableCommand: SerializableCommand { fn get_raw_name(&self) -> &'static str; fn get_minimum_version(&self) -> ProtocolVersion; } +impl BasicWritableCommand for Box { + fn get_raw_name(&self) -> &'static str { + (**self).get_raw_name() + } + + fn get_minimum_version(&self) -> ProtocolVersion { + (**self).get_minimum_version() + } +} + +impl BasicWritableCommand for &'_ Box { + fn get_raw_name(&self) -> &'static str { + (**self).get_raw_name() + } + + fn get_minimum_version(&self) -> ProtocolVersion { + (**self).get_minimum_version() + } +} + pub trait WritableCommand: BasicWritableCommand { fn get_mask_flag(&self) -> HashMap; fn get_flag(&self) -> f64;