Trait uleb128::WriteULeb128Ext [−][src]
pub trait WriteULeb128Ext: Write { fn write_uleb128_u32(&mut self, value: u32) -> Result { ... } fn write_uleb128_u64(&mut self, value: u64) -> Result { ... } }
Extends Write
with methods for writing unsigned integers to the
underlying writer encoded in unsigned LEB128.
Examples
Write unsigned integers to a writer encoded in LEB128:
use uleb128::WriteULeb128Ext; let mut wtr = vec![]; wtr.write_uleb128_u32(127).unwrap(); wtr.write_uleb128_u32(128).unwrap(); wtr.write_uleb128_u32(129).unwrap(); assert_eq!(wtr, vec![ 0b0111_1111, // 127 0b1000_0000, 0b0000_0001, // 128 0b1000_0001, 0b0000_0001, // 129 ]);
Provided methods
fn write_uleb128_u32(&mut self, value: u32) -> Result
[src]
Write an unsigned 32-bit integer to the underlying writer encoded in unsigned LEB128.
Errors
If this function encounters an error when performing an I/O operation,
then this function immediately returns an Error::Io
to propagate the
io::Error
returned by an internal call to Write::write_all
.
Examples
Write an unsigned 32-bit integer to a writer encoded in LEB128:
use uleb128::WriteULeb128Ext; let mut wtr = vec![]; wtr.write_uleb128_u32(2_147_483_647).unwrap(); assert_eq!(wtr, vec![ // 2_147_483_647 0b1111_1111, 0b1111_1111, 0b1111_1111, 0b1111_1111, 0b0000_0111 ]);
fn write_uleb128_u64(&mut self, value: u64) -> Result
[src]
Write an unsigned 64-bit integer to the underlying writer encoded in unsigned LEB128.
Errors
If this function encounters an error when performing an I/O operation,
then this function immediately returns an Error::Io
to propagate the
io::Error
returned by an internal call to Write::write_all
.
Examples
Write an unsigned 64-bit integer to a writer encoded in LEB128:
use uleb128::WriteULeb128Ext; let mut wtr = vec![]; wtr.write_uleb128_u64(9_223_372_036_854_775_807).unwrap(); assert_eq!(wtr, vec![ // 9_223_372_036_854_775_807 0b1111_1111, 0b1111_1111, 0b1111_1111, 0b1111_1111, 0b1111_1111, 0b1111_1111, 0b1111_1111, 0b1111_1111, 0b0111_1111 ]);
Implementors
impl<W: Write + ?Sized> WriteULeb128Ext for W
[src]
impl<W: Write + ?Sized> WriteULeb128Ext for W
[src]