moq_transport/data/
object_status.rs1use crate::coding::{Decode, DecodeError, Encode, EncodeError};
2
3#[derive(Clone, Copy, Debug, Eq, PartialEq)]
4pub enum ObjectStatus {
5 NormalObject = 0x0,
6 ObjectDoesNotExist = 0x1,
7 EndOfGroup = 0x3,
8 EndOfTrack = 0x4,
9}
10
11impl Decode for ObjectStatus {
12 fn decode<B: bytes::Buf>(r: &mut B) -> Result<Self, DecodeError> {
13 match u64::decode(r)? {
14 0x0 => Ok(Self::NormalObject),
15 0x1 => Ok(Self::ObjectDoesNotExist),
16 0x3 => Ok(Self::EndOfGroup),
17 0x4 => Ok(Self::EndOfTrack),
18 _ => Err(DecodeError::InvalidObjectStatus),
19 }
20 }
21}
22
23impl Encode for ObjectStatus {
24 fn encode<W: bytes::BufMut>(&self, w: &mut W) -> Result<(), EncodeError> {
25 let val = *self as u64;
26 val.encode(w)?;
27 Ok(())
28 }
29}