blob: 06d6ba8c4dc899da8012a9d2f6f4da0a1a0a31a8 (
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
26
27
28
29
|
#[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,
}
}
}
impl Into<usize> for EbmlSize {
fn into(self) -> usize {
match self {
EbmlSize::Exact(s) => s,
EbmlSize::Unknown => panic!("unknown size, where it should have been known"),
}
}
}
|