ddp_rs/protocol/timecode.rs
1#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy, Default)]
2pub struct TimeCode(pub Option<u32>);
3
4impl TimeCode {
5 pub fn from_4_bytes(bytes: [u8; 4]) -> Self {
6 TimeCode(Some(u32::from_be_bytes(bytes)))
7 }
8
9 pub fn to_bytes(&self) -> [u8; 4] {
10 self.0.unwrap_or(0u32).to_be_bytes()
11 }
12}