Skip to main content

moqtap_codec/draft12/
types.rs

1//! Draft-12 types.
2
3/// Object status values (draft-12, same numbering as draft-08/11).
4#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5#[repr(u8)]
6pub enum ObjectStatus {
7    /// Object payload follows normally.
8    Normal = 0,
9    /// The referenced object does not exist.
10    ObjectDoesNotExist = 1,
11    /// The referenced group does not exist.
12    GroupDoesNotExist = 2,
13    /// Last object in the group.
14    EndOfGroup = 3,
15    /// Last object in the track.
16    EndOfTrack = 4,
17    /// Last object in the subgroup.
18    EndOfSubgroup = 5,
19}
20
21impl ObjectStatus {
22    /// Convert a raw u64 to an `ObjectStatus`, if valid.
23    pub fn from_u64(v: u64) -> Option<Self> {
24        match v {
25            0 => Some(ObjectStatus::Normal),
26            1 => Some(ObjectStatus::ObjectDoesNotExist),
27            2 => Some(ObjectStatus::GroupDoesNotExist),
28            3 => Some(ObjectStatus::EndOfGroup),
29            4 => Some(ObjectStatus::EndOfTrack),
30            5 => Some(ObjectStatus::EndOfSubgroup),
31            _ => None,
32        }
33    }
34}