diff options
Diffstat (limited to 'matroska/src/read.rs')
| -rw-r--r-- | matroska/src/read.rs | 14 | 
1 files changed, 14 insertions, 0 deletions
| diff --git a/matroska/src/read.rs b/matroska/src/read.rs index cb3e45e..42f0e34 100644 --- a/matroska/src/read.rs +++ b/matroska/src/read.rs @@ -46,12 +46,14 @@ impl EbmlReader {          }      } +    #[inline]      pub fn read_byte(&mut self) -> Result<u8> {          let mut b = [0u8];          self.inner.read_exact(&mut b).map_err(Error::Io)?;          self.position += 1;          Ok(b[0])      } +          pub fn read_buf(&mut self, size: impl Into<usize>) -> Result<Vec<u8>> {          let size = size.into();          let mut b = vec![0u8; size]; @@ -59,6 +61,7 @@ impl EbmlReader {          self.position += size;          Ok(b)      } +          pub fn read_vint_len(&mut self) -> Result<(u64, usize)> {          let s = self.read_byte()?;          let len = s.leading_zeros() + 1; @@ -73,20 +76,30 @@ impl EbmlReader {          }          Ok((value, len as usize))      } +     +    #[inline]      pub fn read_vint(&mut self) -> Result<u64> {          Ok(self.read_vint_len()?.0)      } +     +    #[inline]      pub fn read_utf8(&mut self, size: impl Into<usize>) -> Result<String> {          let b = self.read_buf(size)?;          Ok(String::from_utf8(b).map_err(|_| Error::InvalidUTF8)?)      } +     +    #[inline]      pub fn read_tag_id(&mut self) -> Result<u64> {          let (value, len) = self.read_vint_len()?;          Ok(value + (1 << (7 * len)))      } +     +    #[inline]      pub fn read_tag_size(&mut self) -> Result<EbmlSize> {          Ok(EbmlSize::from_vint(self.read_vint_len()?))      } + +    /// reads *some* amount of tags from the stream and pushes it to the queue.      pub fn read_stuff(&mut self) -> Result<()> {          while let Some(e) = self.stack.last().copied() {              if let Some(end) = e.end { @@ -284,6 +297,7 @@ impl<T: Read> ReadExt for T {          }          Ok((value, len as usize))      } +    #[inline]      fn read_vint(&mut self) -> Result<u64> {          Ok(self.read_vint_len()?.0)      } | 
