chore: Begone &Box<T>
This commit is contained in:
parent
2325645bb5
commit
689138b282
|
@ -82,7 +82,7 @@ pub struct AtemSocketCommand {
|
|||
}
|
||||
|
||||
impl AtemSocketCommand {
|
||||
pub fn new(command: &Box<dyn BasicWritableCommand>, version: &ProtocolVersion) -> Self {
|
||||
pub fn new<C: BasicWritableCommand>(command: &C, version: &ProtocolVersion) -> Self {
|
||||
Self {
|
||||
payload: command.payload(version),
|
||||
raw_name: command.get_raw_name().to_string(),
|
||||
|
|
|
@ -15,11 +15,43 @@ pub trait SerializableCommand {
|
|||
fn payload(&self, version: &ProtocolVersion) -> Vec<u8>;
|
||||
}
|
||||
|
||||
impl<C: SerializableCommand + ?Sized> SerializableCommand for Box<C> {
|
||||
fn payload(&self, version: &ProtocolVersion) -> Vec<u8> {
|
||||
(**self).payload(version)
|
||||
}
|
||||
}
|
||||
|
||||
impl<C: SerializableCommand + ?Sized> SerializableCommand for &'_ Box<C> {
|
||||
fn payload(&self, version: &ProtocolVersion) -> Vec<u8> {
|
||||
(**self).payload(version)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait BasicWritableCommand: SerializableCommand {
|
||||
fn get_raw_name(&self) -> &'static str;
|
||||
fn get_minimum_version(&self) -> ProtocolVersion;
|
||||
}
|
||||
|
||||
impl<C: BasicWritableCommand + ?Sized> BasicWritableCommand for Box<C> {
|
||||
fn get_raw_name(&self) -> &'static str {
|
||||
(**self).get_raw_name()
|
||||
}
|
||||
|
||||
fn get_minimum_version(&self) -> ProtocolVersion {
|
||||
(**self).get_minimum_version()
|
||||
}
|
||||
}
|
||||
|
||||
impl<C: BasicWritableCommand + ?Sized> BasicWritableCommand for &'_ Box<C> {
|
||||
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<String, f64>;
|
||||
fn get_flag(&self) -> f64;
|
||||
|
|
Loading…
Reference in New Issue