blob: 7ef0de9d09a7063df1d714db3e317a4a4d5f02c9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
/*
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) 2025 metamuffin <metamuffin.org>
*/
#[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<usize> {
match self {
EbmlSize::Exact(s) => Some(s),
EbmlSize::Unknown => None,
}
}
}
|