[][src]Struct nano_leb128::ULEB128

pub struct ULEB128(_);

A value that can be (de)serialized using unsigned LEB128 variable length compression.

Examples

Deserializing a value that was serialized using unsigned LEB128 variable length compression:

use nano_leb128::ULEB128;

let buf = [0xE5, 0x8E, 0x26];

let (val, len) = ULEB128::read_from(&buf).unwrap();

assert_eq!(u64::from(val), 624485);
assert_eq!(len, 3);

Serializing a value using unsigned LEB128 variable length compression:

use nano_leb128::ULEB128;

let mut buf = [0; 3];

assert_eq!(ULEB128::from(624485).write_into(&mut buf).unwrap(), 3);
assert_eq!(buf, [0xE5, 0x8E, 0x26]);

Methods

impl ULEB128[src]

pub fn read_from(buf: &[u8]) -> Result<(Self, usize), LEB128DecodeError>[src]

Attempts to read an unsigned LEB128 compressed value from a buffer.

On success this will return the decompressed value and the number of bytes that were read.

pub fn write_into(self, buf: &mut [u8]) -> Result<usize, LEB128EncodeError>[src]

Attempts to write a value into a buffer using unsigned LEB128 compression.

On success this will return the number of bytes that were written.

Trait Implementations

impl PartialEq<ULEB128> for ULEB128[src]

impl Eq for ULEB128[src]

impl Copy for ULEB128[src]

impl Debug for ULEB128[src]

impl From<ULEB128> for u64[src]

impl From<u64> for ULEB128[src]

impl Clone for ULEB128[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl Send for ULEB128

impl Sync for ULEB128

impl Unpin for ULEB128

impl UnwindSafe for ULEB128

impl RefUnwindSafe for ULEB128

Blanket Implementations

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.