1
- use crate :: ebml:: vint:: VInt ;
1
+ use crate :: ebml:: vint:: { ElementId , VInt } ;
2
2
use crate :: error:: Result ;
3
3
use crate :: macros:: { decode_err, try_vec} ;
4
4
@@ -10,8 +10,8 @@ use lofty_attr::ebml_master_elements;
10
10
11
11
#[ derive( Copy , Clone , Eq , PartialEq , Debug ) ]
12
12
pub struct ElementHeader {
13
- pub ( crate ) id : VInt ,
14
- pub ( crate ) size : VInt ,
13
+ pub ( crate ) id : ElementId ,
14
+ pub ( crate ) size : VInt < u64 > ,
15
15
}
16
16
17
17
impl ElementHeader {
@@ -20,8 +20,8 @@ impl ElementHeader {
20
20
R : Read ,
21
21
{
22
22
Ok ( Self {
23
- id : VInt :: parse_from_element_id ( reader, max_id_length) ?,
24
- size : VInt :: parse ( reader, max_vint_length) ?,
23
+ id : ElementId :: parse ( reader, max_id_length) ?,
24
+ size : VInt :: < u64 > :: parse ( reader, max_vint_length) ?,
25
25
} )
26
26
}
27
27
}
@@ -41,7 +41,7 @@ pub enum ElementDataType {
41
41
#[ derive( Copy , Clone , Debug ) ]
42
42
struct MasterElement {
43
43
id : ElementIdent ,
44
- children : & ' static [ ( VInt , ChildElementDescriptor ) ] ,
44
+ children : & ' static [ ( ElementId , ChildElementDescriptor ) ] ,
45
45
}
46
46
47
47
#[ derive( Copy , Clone , Debug ) ]
@@ -247,7 +247,7 @@ const ROOT_DEPTH: u8 = 1;
247
247
#[ derive( Copy , Clone , Debug ) ]
248
248
struct Depth {
249
249
level : u8 ,
250
- length : VInt ,
250
+ length : VInt < u64 > ,
251
251
}
252
252
253
253
#[ derive( Copy , Clone , Debug ) ]
@@ -302,7 +302,7 @@ impl ElementReaderContext {
302
302
self . masters . get ( ( self . depth - 1 ) as usize ) . copied ( )
303
303
}
304
304
305
- fn current_master_length ( & self ) -> VInt {
305
+ fn current_master_length ( & self ) -> VInt < u64 > {
306
306
assert ! ( self . depth > 0 ) ;
307
307
self . current_master ( )
308
308
. expect ( "should have current master element" )
@@ -316,7 +316,7 @@ impl ElementReaderContext {
316
316
}
317
317
}
318
318
319
- fn remaining_lock_length ( & self ) -> VInt {
319
+ fn remaining_lock_length ( & self ) -> VInt < u64 > {
320
320
assert ! ( self . locked && !self . lock_depths. is_empty( ) ) ;
321
321
322
322
let lock_depth = * self . lock_depths . last ( ) . unwrap ( ) ;
@@ -326,8 +326,8 @@ impl ElementReaderContext {
326
326
327
327
#[ derive( Debug ) ]
328
328
pub ( crate ) enum ElementReaderYield {
329
- Master ( ( ElementIdent , VInt ) ) ,
330
- Child ( ( ChildElementDescriptor , VInt ) ) ,
329
+ Master ( ( ElementIdent , VInt < u64 > ) ) ,
330
+ Child ( ( ChildElementDescriptor , VInt < u64 > ) ) ,
331
331
Unknown ( ElementHeader ) ,
332
332
Eof ,
333
333
}
@@ -412,7 +412,7 @@ where
412
412
self . ctx . max_size_length = len
413
413
}
414
414
415
- fn push_new_master ( & mut self , master : MasterElement , size : VInt ) -> Result < ( ) > {
415
+ fn push_new_master ( & mut self , master : MasterElement , size : VInt < u64 > ) -> Result < ( ) > {
416
416
log:: debug!( "New master element: {:?}" , master. id) ;
417
417
418
418
if self . ctx . depth == MAX_DEPTH {
@@ -662,7 +662,7 @@ where
662
662
// https://www.rfc-editor.org/rfc/rfc8794.html#section-7.8
663
663
// A Binary Element MUST declare a length in octets from zero to VINTMAX.
664
664
665
- if element_length > VInt :: MAX {
665
+ if element_length > VInt :: < u64 > :: MAX {
666
666
decode_err ! ( @BAIL Ebml , "Binary element length is too large" )
667
667
}
668
668
0 commit comments