[−][src]Struct nano_leb128::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]
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]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,