#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum EbmlSize { Exact(usize), Unknown, } impl EbmlSize { pub fn from_vint((value, len): (u64, usize)) -> EbmlSize { if value == ((1 << (7 * len)) - 1) { Self::Unknown } else { Self::Exact(value as usize) } } pub fn some(self) -> Option { match self { EbmlSize::Exact(s) => Some(s), EbmlSize::Unknown => None, } } } impl Into for EbmlSize { fn into(self) -> usize { match self { EbmlSize::Exact(s) => s, EbmlSize::Unknown => panic!("unknown size, where it should have been known"), } } }