Crate uleb128[][src]

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 ReadULeb128Ext and the WriteULeb128Ext extension traits.

Traits

ReadULeb128Ext

Extends Read with methods for reading numbers encoded in [unsigned LEB128*]

WriteULeb128Ext

Extends Write with 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.

Type Definitions

Result

A specialized Result type for unsigned LEB128 operations.