pub trait Varint:
Clone
+ Copy
+ Debug
+ Default
+ Eq
+ Hash
+ Ord
+ PartialEq
+ PartialOrd
+ Sized
+ Sealed {
type Buf: Default + 'static;
const MAX_LEN: usize;
// Required methods
fn encoded_len(self) -> usize;
fn read(buf: &[u8]) -> Result<(Self, usize), Overflow>;
fn read_iter<I>(iter: I) -> Result<(Self, usize), Overflow>
where I: IntoIterator<Item = u8>;
fn write(self, buf: &mut Self::Buf) -> &[u8] ⓘ;
fn try_write(self, buf: &mut [u8]) -> Option<&[u8]>;
}Expand description
An integer that can be LEB128-encoded.
Required Associated Constants§
Required Associated Types§
Required Methods§
Sourcefn encoded_len(self) -> usize
fn encoded_len(self) -> usize
Returns the number of bytes needed to encode the integer.
Sourcefn read(buf: &[u8]) -> Result<(Self, usize), Overflow>
fn read(buf: &[u8]) -> Result<(Self, usize), Overflow>
Decodes a LEB128-encoded integer from buf.
It returns the decoded integer and the number of bytes read.
Sourcefn read_iter<I>(iter: I) -> Result<(Self, usize), Overflow>where
I: IntoIterator<Item = u8>,
fn read_iter<I>(iter: I) -> Result<(Self, usize), Overflow>where
I: IntoIterator<Item = u8>,
Decodes a LEB128-encoded integer from iter.
It returns the decoded integer and the number of bytes read.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.