/* This file is part of jellything (https://codeberg.org/metamuffin/jellything) which is licensed under the GNU Affero General Public License (version 3); see /COPYING. Copyright (C) 2024 metamuffin */ #[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, } } }