scte35_splice/commands/
splice_null.rs1use crate::error::{Error, Result};
7use crate::traits::CommandDef;
8use broadcast_common::{Parse, Serialize};
9
10pub const COMMAND_TYPE: u8 = 0x00;
12
13#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
15#[cfg_attr(feature = "serde", derive(serde::Serialize))]
16pub struct SpliceNull;
17
18impl<'a> Parse<'a> for SpliceNull {
19 type Error = Error;
20 fn parse(_bytes: &'a [u8]) -> Result<Self> {
21 Ok(Self)
22 }
23}
24
25impl Serialize for SpliceNull {
26 type Error = Error;
27 fn serialized_len(&self) -> usize {
28 0
29 }
30 fn serialize_into(&self, _buf: &mut [u8]) -> Result<usize> {
31 Ok(0)
32 }
33}
34
35impl<'a> CommandDef<'a> for SpliceNull {
36 const COMMAND_TYPE: u8 = COMMAND_TYPE;
37 const NAME: &'static str = "SPLICE_NULL";
38}
39
40#[cfg(test)]
41mod tests {
42 use super::*;
43
44 #[test]
45 fn round_trip_empty() {
46 let cmd = SpliceNull;
47 assert_eq!(cmd.serialized_len(), 0);
48 let bytes = cmd.to_bytes();
49 assert!(bytes.is_empty());
50 assert_eq!(SpliceNull::parse(&bytes).unwrap(), cmd);
51 }
52}