@@ -22,7 +22,12 @@ impl<'a> Reader<'a> {
2222 Self { buffer, off : 0 }
2323 }
2424
25- fn read_u8 ( & mut self ) -> u8 {
25+ /// Reads the next [`u8`] from the buffer and updates the internal pointer.
26+ ///
27+ /// # Panic
28+ ///
29+ /// Panics if the index is out of bounds.
30+ fn read_next_u8 ( & mut self ) -> u8 {
2631 let val = self
2732 . buffer
2833 . get ( self . off )
@@ -36,9 +41,14 @@ impl<'a> Reader<'a> {
3641 val
3742 }
3843
39- fn read_u16 ( & mut self ) -> u16 {
40- let u16_lo = self . read_u8 ( ) as u16 ;
41- let u16_hi = self . read_u8 ( ) as u16 ;
44+ /// Reads the next [`u16`] from the buffer and updates the internal pointer.
45+ ///
46+ /// # Panic
47+ ///
48+ /// Panics if the index is out of bounds.
49+ fn read_next_u16 ( & mut self ) -> u16 {
50+ let u16_lo = self . read_next_u8 ( ) as u16 ;
51+ let u16_hi = self . read_next_u8 ( ) as u16 ;
4252 ( u16_hi << 8 ) | u16_lo
4353 }
4454
@@ -168,7 +178,7 @@ impl FramebufferTag {
168178 // TODO we can create a struct for this and implement
169179 // DynSizedStruct for it to leverage the already existing
170180 // functionality
171- let num_colors = reader. read_u16 ( ) ;
181+ let num_colors = reader. read_next_u16 ( ) ;
172182
173183 let palette = {
174184 // Ensure the slice can be created without causing UB
@@ -184,12 +194,12 @@ impl FramebufferTag {
184194 Ok ( FramebufferType :: Indexed { palette } )
185195 }
186196 FramebufferTypeId :: RGB => {
187- let red_pos = reader. read_u8 ( ) ; // These refer to the bit positions of the LSB of each field
188- let red_mask = reader. read_u8 ( ) ; // And then the length of the field from LSB to MSB
189- let green_pos = reader. read_u8 ( ) ;
190- let green_mask = reader. read_u8 ( ) ;
191- let blue_pos = reader. read_u8 ( ) ;
192- let blue_mask = reader. read_u8 ( ) ;
197+ let red_pos = reader. read_next_u8 ( ) ; // These refer to the bit positions of the LSB of each field
198+ let red_mask = reader. read_next_u8 ( ) ; // And then the length of the field from LSB to MSB
199+ let green_pos = reader. read_next_u8 ( ) ;
200+ let green_mask = reader. read_next_u8 ( ) ;
201+ let blue_pos = reader. read_next_u8 ( ) ;
202+ let blue_mask = reader. read_next_u8 ( ) ;
193203 Ok ( FramebufferType :: RGB {
194204 red : FramebufferField {
195205 position : red_pos,
0 commit comments