#[repr(transparent)]pub struct Uleb128<T>(pub T);Expand description
Encodes just this integer as unsigned LEB128, using zigzag for signed values.
Each byte carries seven low-order bits and a continuation bit. This wrapper ignores the configuration’s integer encoding and endianness; ordinary values alongside it continue to use the enclosing configuration. Decode with the same wrapper and integer type. All Rust signed and unsigned integer types are supported.
use cu_bincode::{config, decode_from_slice, encode_into_slice, Uleb128};
let mut bytes = [0; 16];
let len = encode_into_slice((300u32, Uleb128(-150i128)), &mut bytes, config::standard()).unwrap();
assert_eq!(&bytes[..len], &[251, 44, 1, 171, 2]);
let (decoded, used) = decode_from_slice::<(u32, Uleb128<i128>), _>(&bytes[..len], config::standard()).unwrap();
assert_eq!(decoded, (300, Uleb128(-150)));
assert_eq!(used, len);Tuple Fields§
§0: TTrait Implementations§
Source§impl<'de, __Context> BorrowDecode<'de, __Context> for Uleb128<u8>
impl<'de, __Context> BorrowDecode<'de, __Context> for Uleb128<u8>
Source§fn borrow_decode<D: BorrowDecoder<'de, Context = __Context>>(
decoder: &mut D,
) -> Result<Self, DecodeError>
fn borrow_decode<D: BorrowDecoder<'de, Context = __Context>>( decoder: &mut D, ) -> Result<Self, DecodeError>
Attempt to decode this type with the given BorrowDecode.
Source§impl<'de, __Context> BorrowDecode<'de, __Context> for Uleb128<u16>
impl<'de, __Context> BorrowDecode<'de, __Context> for Uleb128<u16>
Source§fn borrow_decode<D: BorrowDecoder<'de, Context = __Context>>(
decoder: &mut D,
) -> Result<Self, DecodeError>
fn borrow_decode<D: BorrowDecoder<'de, Context = __Context>>( decoder: &mut D, ) -> Result<Self, DecodeError>
Attempt to decode this type with the given BorrowDecode.
Source§impl<'de, __Context> BorrowDecode<'de, __Context> for Uleb128<u32>
impl<'de, __Context> BorrowDecode<'de, __Context> for Uleb128<u32>
Source§fn borrow_decode<D: BorrowDecoder<'de, Context = __Context>>(
decoder: &mut D,
) -> Result<Self, DecodeError>
fn borrow_decode<D: BorrowDecoder<'de, Context = __Context>>( decoder: &mut D, ) -> Result<Self, DecodeError>
Attempt to decode this type with the given BorrowDecode.
Source§impl<'de, __Context> BorrowDecode<'de, __Context> for Uleb128<u64>
impl<'de, __Context> BorrowDecode<'de, __Context> for Uleb128<u64>
Source§fn borrow_decode<D: BorrowDecoder<'de, Context = __Context>>(
decoder: &mut D,
) -> Result<Self, DecodeError>
fn borrow_decode<D: BorrowDecoder<'de, Context = __Context>>( decoder: &mut D, ) -> Result<Self, DecodeError>
Attempt to decode this type with the given BorrowDecode.
Source§impl<'de, __Context> BorrowDecode<'de, __Context> for Uleb128<u128>
impl<'de, __Context> BorrowDecode<'de, __Context> for Uleb128<u128>
Source§fn borrow_decode<D: BorrowDecoder<'de, Context = __Context>>(
decoder: &mut D,
) -> Result<Self, DecodeError>
fn borrow_decode<D: BorrowDecoder<'de, Context = __Context>>( decoder: &mut D, ) -> Result<Self, DecodeError>
Attempt to decode this type with the given BorrowDecode.
Source§impl<'de, __Context> BorrowDecode<'de, __Context> for Uleb128<usize>
impl<'de, __Context> BorrowDecode<'de, __Context> for Uleb128<usize>
Source§fn borrow_decode<D: BorrowDecoder<'de, Context = __Context>>(
decoder: &mut D,
) -> Result<Self, DecodeError>
fn borrow_decode<D: BorrowDecoder<'de, Context = __Context>>( decoder: &mut D, ) -> Result<Self, DecodeError>
Attempt to decode this type with the given BorrowDecode.
Source§impl<'de, __Context> BorrowDecode<'de, __Context> for Uleb128<i8>
impl<'de, __Context> BorrowDecode<'de, __Context> for Uleb128<i8>
Source§fn borrow_decode<D: BorrowDecoder<'de, Context = __Context>>(
decoder: &mut D,
) -> Result<Self, DecodeError>
fn borrow_decode<D: BorrowDecoder<'de, Context = __Context>>( decoder: &mut D, ) -> Result<Self, DecodeError>
Attempt to decode this type with the given BorrowDecode.
Source§impl<'de, __Context> BorrowDecode<'de, __Context> for Uleb128<i16>
impl<'de, __Context> BorrowDecode<'de, __Context> for Uleb128<i16>
Source§fn borrow_decode<D: BorrowDecoder<'de, Context = __Context>>(
decoder: &mut D,
) -> Result<Self, DecodeError>
fn borrow_decode<D: BorrowDecoder<'de, Context = __Context>>( decoder: &mut D, ) -> Result<Self, DecodeError>
Attempt to decode this type with the given BorrowDecode.
Source§impl<'de, __Context> BorrowDecode<'de, __Context> for Uleb128<i32>
impl<'de, __Context> BorrowDecode<'de, __Context> for Uleb128<i32>
Source§fn borrow_decode<D: BorrowDecoder<'de, Context = __Context>>(
decoder: &mut D,
) -> Result<Self, DecodeError>
fn borrow_decode<D: BorrowDecoder<'de, Context = __Context>>( decoder: &mut D, ) -> Result<Self, DecodeError>
Attempt to decode this type with the given BorrowDecode.
Source§impl<'de, __Context> BorrowDecode<'de, __Context> for Uleb128<i64>
impl<'de, __Context> BorrowDecode<'de, __Context> for Uleb128<i64>
Source§fn borrow_decode<D: BorrowDecoder<'de, Context = __Context>>(
decoder: &mut D,
) -> Result<Self, DecodeError>
fn borrow_decode<D: BorrowDecoder<'de, Context = __Context>>( decoder: &mut D, ) -> Result<Self, DecodeError>
Attempt to decode this type with the given BorrowDecode.
Source§impl<'de, __Context> BorrowDecode<'de, __Context> for Uleb128<i128>
impl<'de, __Context> BorrowDecode<'de, __Context> for Uleb128<i128>
Source§fn borrow_decode<D: BorrowDecoder<'de, Context = __Context>>(
decoder: &mut D,
) -> Result<Self, DecodeError>
fn borrow_decode<D: BorrowDecoder<'de, Context = __Context>>( decoder: &mut D, ) -> Result<Self, DecodeError>
Attempt to decode this type with the given BorrowDecode.
Source§impl<'de, __Context> BorrowDecode<'de, __Context> for Uleb128<isize>
impl<'de, __Context> BorrowDecode<'de, __Context> for Uleb128<isize>
Source§fn borrow_decode<D: BorrowDecoder<'de, Context = __Context>>(
decoder: &mut D,
) -> Result<Self, DecodeError>
fn borrow_decode<D: BorrowDecoder<'de, Context = __Context>>( decoder: &mut D, ) -> Result<Self, DecodeError>
Attempt to decode this type with the given BorrowDecode.
impl<T: Copy> Copy for Uleb128<T>
impl<T: Eq> Eq for Uleb128<T>
Source§impl<T: Ord> Ord for Uleb128<T>
impl<T: Ord> Ord for Uleb128<T>
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl<T: PartialOrd> PartialOrd for Uleb128<T>
impl<T: PartialOrd> PartialOrd for Uleb128<T>
impl<T: PartialEq> StructuralPartialEq for Uleb128<T>
Auto Trait Implementations§
impl<T> Freeze for Uleb128<T>where
T: Freeze,
impl<T> RefUnwindSafe for Uleb128<T>where
T: RefUnwindSafe,
impl<T> Send for Uleb128<T>where
T: Send,
impl<T> Sync for Uleb128<T>where
T: Sync,
impl<T> Unpin for Uleb128<T>where
T: Unpin,
impl<T> UnsafeUnpin for Uleb128<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Uleb128<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more