From 476a24ded96045de7968ad512c719b5af4693d64 Mon Sep 17 00:00:00 2001 From: Baud Date: Mon, 5 Feb 2024 20:33:01 +0000 Subject: [PATCH] chore: Some cleanups --- atem-connection-rs/src/atem.rs | 4 ++-- .../src/atem_lib/atem_socket_inner.rs | 1 + .../src/commands/command_base.rs | 20 +++++++++---------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/atem-connection-rs/src/atem.rs b/atem-connection-rs/src/atem.rs index c293e7f..07e00aa 100644 --- a/atem-connection-rs/src/atem.rs +++ b/atem-connection-rs/src/atem.rs @@ -1,4 +1,4 @@ -use crate::{commands::command_base::IDeserializedCommand, state::AtemState}; +use crate::{commands::command_base::DeserializedCommand, state::AtemState}; pub struct AtemOptions { address: Option, @@ -15,5 +15,5 @@ pub enum AtemEvents { Connected, Disconnected, StateChanged(Box<(AtemState, Vec)>), - ReceivedCommands(Vec>), + ReceivedCommands(Vec>), } diff --git a/atem-connection-rs/src/atem_lib/atem_socket_inner.rs b/atem-connection-rs/src/atem_lib/atem_socket_inner.rs index f1e8747..c9c2594 100644 --- a/atem-connection-rs/src/atem_lib/atem_socket_inner.rs +++ b/atem-connection-rs/src/atem_lib/atem_socket_inner.rs @@ -301,6 +301,7 @@ impl AtemSocketInner { let remote_packet_id = u16::from_be_bytes(packet[10..12].try_into().unwrap()); if flags & u8::from(PacketFlag::NewSessionId) > 0 { + debug!("New session"); self.connection_state = ConnectionState::Established; self.last_received_packed_id = remote_packet_id; self.send_ack(remote_packet_id).await; diff --git a/atem-connection-rs/src/commands/command_base.rs b/atem-connection-rs/src/commands/command_base.rs index 7ebecaf..896e73a 100644 --- a/atem-connection-rs/src/commands/command_base.rs +++ b/atem-connection-rs/src/commands/command_base.rs @@ -2,22 +2,22 @@ use std::collections::HashMap; use crate::{enums::ProtocolVersion, state::AtemState}; -pub trait IDeserializedCommand { +pub trait DeserializedCommand { fn apply_to_state(&self, state: &mut AtemState) -> Vec; } -pub trait DeserializedCommand: IDeserializedCommand { - fn get_raw_name(&self) -> Option; - fn get_minimum_version(&self) -> Option; +pub trait DeserializableCommand: DeserializedCommand { + fn get_raw_name(&self) -> &'static str; + fn get_minimum_version(&self) -> ProtocolVersion; } -pub trait ISerializableCommand { - fn serialize(version: ProtocolVersion) -> Vec; +pub trait SerializableCommand { + fn payload(&self, version: ProtocolVersion) -> Vec; } -pub trait BasicWritableCommand: ISerializableCommand { - fn get_raw_name(&self) -> Option; - fn get_minimum_version(&self) -> Option; +pub trait BasicWritableCommand: SerializableCommand { + fn get_raw_name(&self) -> &'static str; + fn get_minimum_version(&self) -> ProtocolVersion; } pub trait WritableCommand: BasicWritableCommand { @@ -26,4 +26,4 @@ pub trait WritableCommand: BasicWritableCommand { fn set_flag(&mut self, flag: f64); } -pub trait SymmetricalCommand: DeserializedCommand + ISerializableCommand {} +pub trait SymmetricalCommand: DeserializableCommand + SerializableCommand {}