-pub struct VoiceFull(pub [u8; 54]);
-impl_stream_id!(VoiceFull, 4);
-impl_link_setup!(VoiceFull, 6);
-impl_frame_number!(VoiceFull, 34);
-impl_payload!(VoiceFull, 36, 52);
-impl_trailing_crc_verify!(VoiceFull);
+impl InterlinkMessage {
+ pub fn parse(bytes: &[u8]) -> Option<Self> {
+ if bytes.len() < 4 {
+ return None;
+ }
+ match &bytes[0..4] {
+ MAGIC_VOICE => Some(Self::VoiceInterlink(VoiceInterlink::from_bytes(bytes)?)),
+ MAGIC_VOICE_HEADER => Some(Self::VoiceHeaderInterlink(
+ VoiceHeaderInterlink::from_bytes(bytes)?,
+ )),
+ MAGIC_VOICE_DATA => Some(Self::VoiceDataInterlink(VoiceDataInterlink::from_bytes(
+ bytes,
+ )?)),
+ MAGIC_PACKET => Some(Self::PacketInterlink(PacketInterlink::from_bytes(bytes)?)),
+ MAGIC_PING => Some(Self::Ping(Ping::from_bytes(bytes)?)),
+ MAGIC_CONNECT => Some(Self::ConnectInterlink(ConnectInterlink::from_bytes(bytes)?)),
+ MAGIC_ACKNOWLEDGE => Some(Self::ConnectInterlinkAcknowledge(
+ ConnectInterlinkAcknowledge::from_bytes(bytes)?,
+ )),
+ MAGIC_NACK => Some(Self::ConnectNack(ConnectNack::from_bytes(bytes)?)),
+ MAGIC_DISCONNECT => Some(Self::DisconnectInterlink(DisconnectInterlink::from_bytes(
+ bytes,
+ )?)),
+ _ => None,
+ }
+ }
+}
+
+define_message!(Voice, 54, 54, MAGIC_VOICE);
+impl_stream_id!(Voice, 4);
+impl_link_setup!(Voice, 6);
+impl_frame_number!(Voice, 34);
+impl_payload!(Voice, 36, 52);
+impl_trailing_crc_verify!(Voice);