[−][src]Trait wasabi_leb128::ReadLeb128
A trait that extends readers (implementers of the io::Read
trait) with a method to parse
LEB128 encoded primitive integers.
Required methods
fn read_leb128(&mut self) -> Result<(T, usize), ParseLeb128Error>
Reads an LEB128 encoded integer of type T
by decoding a sequence of bytes from self
.
If successful, it returns the parsed value and the number of bytes consumed from self
,
otherwise a ParseLeb128Error
.
Example
use wasabi_leb128::ReadLeb128; // Wrap the array in an io::Cursor, which implements io::Read. let mut buf = std::io::Cursor::new([0x80, 0x01]); let (value, bytes_read): (u8, usize) = buf.read_leb128().unwrap(); assert_eq!(value, 128); assert_eq!(bytes_read, 2);
Implementors
impl<R, T> ReadLeb128<T> for R where
R: Read,
T: PrimInt + 'static,
u8: AsPrimitive<T>,
[src]
R: Read,
T: PrimInt + 'static,
u8: AsPrimitive<T>,
Combined implementation for reading LEB128 to signed and unsigned primitive integers.