Expand description
Extension traits that allow for the reading and writing of unsigned LEB128 integer values.
§Read
To read unsigned LEB128 integers, do so through the ReadULeb128Ext
extension trait. Importing this trait into a file allows for reading
unsigned integers encoded in unsigned LEB128 from any type that implements
Read.
use std::io::Cursor;
use uleb128::ReadULeb128Ext;
let mut rdr = Cursor::new(vec![0b1000_0000, 0b0000_0001]);
assert_eq!(128, rdr.read_uleb128_u32().unwrap());§Write
To write unsigned integers as unsigned LEB128, do so through the
WriteULeb128Ext extension trait. Importing this trait into a file allows
for writing unsigned integers as unsigned LEB128 from any type that
implements Write.
use uleb128::WriteULeb128Ext;
let mut wtr = vec![];
wtr.write_uleb128_u32(128).unwrap();
assert_eq!(wtr, vec![0b1000_0000, 0b0000_0001]);Enums§
- Error
- The error type for LEB128 operations of the
ReadULeb128Extand theWriteULeb128Extextension traits.
Traits§
- ReadU
Leb128 Ext - Extends
Readwith methods for reading numbers encoded in [unsigned LEB128*] - WriteU
Leb128 Ext - Extends
Writewith methods for writing unsigned integers to the underlying writer encoded in unsigned LEB128.
Functions§
- uleb128_
u32_ len - Get the length of the unsigned 32-bit integer’s unsigned LEB128 representation in bytes.
- uleb128_
u64_ len - Get the length of the unsigned 64-bit integer’s unsigned LEB128 representation in bytes.