chore: Some cleanups

This commit is contained in:
Baud 2024-02-05 20:33:01 +00:00
parent d68b07688a
commit 476a24ded9
3 changed files with 13 additions and 12 deletions

View File

@ -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<String>,
@ -15,5 +15,5 @@ pub enum AtemEvents {
Connected,
Disconnected,
StateChanged(Box<(AtemState, Vec<String>)>),
ReceivedCommands(Vec<Box<dyn IDeserializedCommand>>),
ReceivedCommands(Vec<Box<dyn DeserializedCommand>>),
}

View File

@ -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;

View File

@ -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<String>;
}
pub trait DeserializedCommand: IDeserializedCommand {
fn get_raw_name(&self) -> Option<String>;
fn get_minimum_version(&self) -> Option<ProtocolVersion>;
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<u8>;
pub trait SerializableCommand {
fn payload(&self, version: ProtocolVersion) -> Vec<u8>;
}
pub trait BasicWritableCommand: ISerializableCommand {
fn get_raw_name(&self) -> Option<String>;
fn get_minimum_version(&self) -> Option<ProtocolVersion>;
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 {}