chore: Some cleanups
This commit is contained in:
parent
d68b07688a
commit
476a24ded9
|
@ -1,4 +1,4 @@
|
||||||
use crate::{commands::command_base::IDeserializedCommand, state::AtemState};
|
use crate::{commands::command_base::DeserializedCommand, state::AtemState};
|
||||||
|
|
||||||
pub struct AtemOptions {
|
pub struct AtemOptions {
|
||||||
address: Option<String>,
|
address: Option<String>,
|
||||||
|
@ -15,5 +15,5 @@ pub enum AtemEvents {
|
||||||
Connected,
|
Connected,
|
||||||
Disconnected,
|
Disconnected,
|
||||||
StateChanged(Box<(AtemState, Vec<String>)>),
|
StateChanged(Box<(AtemState, Vec<String>)>),
|
||||||
ReceivedCommands(Vec<Box<dyn IDeserializedCommand>>),
|
ReceivedCommands(Vec<Box<dyn DeserializedCommand>>),
|
||||||
}
|
}
|
||||||
|
|
|
@ -301,6 +301,7 @@ impl AtemSocketInner {
|
||||||
let remote_packet_id = u16::from_be_bytes(packet[10..12].try_into().unwrap());
|
let remote_packet_id = u16::from_be_bytes(packet[10..12].try_into().unwrap());
|
||||||
|
|
||||||
if flags & u8::from(PacketFlag::NewSessionId) > 0 {
|
if flags & u8::from(PacketFlag::NewSessionId) > 0 {
|
||||||
|
debug!("New session");
|
||||||
self.connection_state = ConnectionState::Established;
|
self.connection_state = ConnectionState::Established;
|
||||||
self.last_received_packed_id = remote_packet_id;
|
self.last_received_packed_id = remote_packet_id;
|
||||||
self.send_ack(remote_packet_id).await;
|
self.send_ack(remote_packet_id).await;
|
||||||
|
|
|
@ -2,22 +2,22 @@ use std::collections::HashMap;
|
||||||
|
|
||||||
use crate::{enums::ProtocolVersion, state::AtemState};
|
use crate::{enums::ProtocolVersion, state::AtemState};
|
||||||
|
|
||||||
pub trait IDeserializedCommand {
|
pub trait DeserializedCommand {
|
||||||
fn apply_to_state(&self, state: &mut AtemState) -> Vec<String>;
|
fn apply_to_state(&self, state: &mut AtemState) -> Vec<String>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait DeserializedCommand: IDeserializedCommand {
|
pub trait DeserializableCommand: DeserializedCommand {
|
||||||
fn get_raw_name(&self) -> Option<String>;
|
fn get_raw_name(&self) -> &'static str;
|
||||||
fn get_minimum_version(&self) -> Option<ProtocolVersion>;
|
fn get_minimum_version(&self) -> ProtocolVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait ISerializableCommand {
|
pub trait SerializableCommand {
|
||||||
fn serialize(version: ProtocolVersion) -> Vec<u8>;
|
fn payload(&self, version: ProtocolVersion) -> Vec<u8>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait BasicWritableCommand: ISerializableCommand {
|
pub trait BasicWritableCommand: SerializableCommand {
|
||||||
fn get_raw_name(&self) -> Option<String>;
|
fn get_raw_name(&self) -> &'static str;
|
||||||
fn get_minimum_version(&self) -> Option<ProtocolVersion>;
|
fn get_minimum_version(&self) -> ProtocolVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait WritableCommand: BasicWritableCommand {
|
pub trait WritableCommand: BasicWritableCommand {
|
||||||
|
@ -26,4 +26,4 @@ pub trait WritableCommand: BasicWritableCommand {
|
||||||
fn set_flag(&mut self, flag: f64);
|
fn set_flag(&mut self, flag: f64);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait SymmetricalCommand: DeserializedCommand + ISerializableCommand {}
|
pub trait SymmetricalCommand: DeserializableCommand + SerializableCommand {}
|
||||||
|
|
Loading…
Reference in New Issue