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 {}