[][src]Struct nano_leb128::SLEB128

pub struct SLEB128(_);

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

Examples

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

use nano_leb128::SLEB128;

let buf = [0xC0, 0xBB, 0x78];

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

assert_eq!(i64::from(val), -123456);
assert_eq!(len, 3);

Serializing a value using signed LEB128 variable length compression:

use nano_leb128::SLEB128;

let mut buf = [0; 3];

assert_eq!(SLEB128::from(-123456).write_into(&mut buf).unwrap(), 3);
assert_eq!(buf, [0xC0, 0xBB, 0x78]);

Methods

impl SLEB128[src]

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

Attempts to read a signed 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 signed LEB128 compression.

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

Trait Implementations

impl PartialEq<SLEB128> for SLEB128[src]

impl Eq for SLEB128[src]

impl Copy for SLEB128[src]

impl Debug for SLEB128[src]

impl From<SLEB128> for i64[src]

impl From<i64> for SLEB128[src]

impl Clone for SLEB128[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 SLEB128

impl Sync for SLEB128

impl Unpin for SLEB128

impl UnwindSafe for SLEB128

impl RefUnwindSafe for SLEB128

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.