pub struct Leb128Codec<T, P = NonStrict> { /* private fields */ }Expand description
Type-level unchecked LEB128 codec.
Encoding is always canonical; P only affects decoding.
§Type Parameters
T: Integer value type to decode from LEB128 bytes and encode into canonical LEB128 bytes.P: Type-level decoding policy implementingLeb128DecodePolicy. Usecrate::Strictto reject non-canonical inputs, orNonStrictto accept non-canonical inputs.
§Examples
use qubit_codec_binary::{
Leb128Codec,
NonStrict,
};
let mut output = [0_u8; Leb128Codec::<u64, NonStrict>::MAX_UNITS_PER_VALUE];
let written = unsafe {
Leb128Codec::<u64, NonStrict>::encode_unchecked(300, &mut output, 0)
};
assert_eq!(2, written);
let (decoded, consumed) = unsafe {
Leb128Codec::<u64, NonStrict>::decode_unchecked(&output[..written], 0)
}.expect("canonical LEB128 value should decode");
assert_eq!(300, decoded);
assert_eq!(2, consumed.get());Implementations§
Source§impl<P> Leb128Codec<u8, P>where
P: Leb128DecodePolicy,
impl<P> Leb128Codec<u8, P>where
P: Leb128DecodePolicy,
Sourcepub const MIN_UNITS_PER_VALUE: usize = 1
pub const MIN_UNITS_PER_VALUE: usize = 1
Minimum number of bytes that can represent a complete value.
Sourcepub const MAX_UNITS_PER_VALUE: usize
pub const MAX_UNITS_PER_VALUE: usize
Maximum number of bytes required to encode or decode this type.
Sourcepub unsafe fn decode_unchecked(
input: &[u8],
index: usize,
) -> Result<(u8, NonZeroUsize), Leb128DecodeError>
pub unsafe fn decode_unchecked( input: &[u8], index: usize, ) -> Result<(u8, NonZeroUsize), Leb128DecodeError>
Decodes a value from input starting at index without bounds
checks.
§Parameters
input: Source byte buffer.index: Start index ininput.
§Returns
Returns the decoded value and the non-zero number of consumed bytes.
§Errors
Returns Leb128DecodeError if the bytes are incomplete,
malformed, or strict decoding rejects a non-canonical
representation.
§Safety
The caller must guarantee that index is a valid boundary and
at least Self::MIN_UNITS_PER_VALUE byte is readable from
index.
Sourcepub unsafe fn encode_unchecked(
value: u8,
output: &mut [u8],
index: usize,
) -> usize
pub unsafe fn encode_unchecked( value: u8, output: &mut [u8], index: usize, ) -> usize
Encodes value into output starting at index without bounds
checks.
§Parameters
value: Value to encode.output: Destination byte buffer.index: Start index inoutput.
§Returns
Returns the number of written bytes.
§Safety
The caller must guarantee that output.as_mut_ptr().add(index)
is valid to write Self::MAX_UNITS_PER_VALUE bytes.
Source§impl<P> Leb128Codec<u16, P>where
P: Leb128DecodePolicy,
impl<P> Leb128Codec<u16, P>where
P: Leb128DecodePolicy,
Sourcepub const MIN_UNITS_PER_VALUE: usize = 1
pub const MIN_UNITS_PER_VALUE: usize = 1
Minimum number of bytes that can represent a complete value.
Sourcepub const MAX_UNITS_PER_VALUE: usize
pub const MAX_UNITS_PER_VALUE: usize
Maximum number of bytes required to encode or decode this type.
Sourcepub unsafe fn decode_unchecked(
input: &[u8],
index: usize,
) -> Result<(u16, NonZeroUsize), Leb128DecodeError>
pub unsafe fn decode_unchecked( input: &[u8], index: usize, ) -> Result<(u16, NonZeroUsize), Leb128DecodeError>
Decodes a value from input starting at index without bounds
checks.
§Parameters
input: Source byte buffer.index: Start index ininput.
§Returns
Returns the decoded value and the non-zero number of consumed bytes.
§Errors
Returns Leb128DecodeError if the bytes are incomplete,
malformed, or strict decoding rejects a non-canonical
representation.
§Safety
The caller must guarantee that index is a valid boundary and
at least Self::MIN_UNITS_PER_VALUE byte is readable from
index.
Sourcepub unsafe fn encode_unchecked(
value: u16,
output: &mut [u8],
index: usize,
) -> usize
pub unsafe fn encode_unchecked( value: u16, output: &mut [u8], index: usize, ) -> usize
Encodes value into output starting at index without bounds
checks.
§Parameters
value: Value to encode.output: Destination byte buffer.index: Start index inoutput.
§Returns
Returns the number of written bytes.
§Safety
The caller must guarantee that output.as_mut_ptr().add(index)
is valid to write Self::MAX_UNITS_PER_VALUE bytes.
Source§impl<P> Leb128Codec<u32, P>where
P: Leb128DecodePolicy,
impl<P> Leb128Codec<u32, P>where
P: Leb128DecodePolicy,
Sourcepub const MIN_UNITS_PER_VALUE: usize = 1
pub const MIN_UNITS_PER_VALUE: usize = 1
Minimum number of bytes that can represent a complete value.
Sourcepub const MAX_UNITS_PER_VALUE: usize
pub const MAX_UNITS_PER_VALUE: usize
Maximum number of bytes required to encode or decode this type.
Sourcepub unsafe fn decode_unchecked(
input: &[u8],
index: usize,
) -> Result<(u32, NonZeroUsize), Leb128DecodeError>
pub unsafe fn decode_unchecked( input: &[u8], index: usize, ) -> Result<(u32, NonZeroUsize), Leb128DecodeError>
Decodes a value from input starting at index without bounds
checks.
§Parameters
input: Source byte buffer.index: Start index ininput.
§Returns
Returns the decoded value and the non-zero number of consumed bytes.
§Errors
Returns Leb128DecodeError if the bytes are incomplete,
malformed, or strict decoding rejects a non-canonical
representation.
§Safety
The caller must guarantee that index is a valid boundary and
at least Self::MIN_UNITS_PER_VALUE byte is readable from
index.
Sourcepub unsafe fn encode_unchecked(
value: u32,
output: &mut [u8],
index: usize,
) -> usize
pub unsafe fn encode_unchecked( value: u32, output: &mut [u8], index: usize, ) -> usize
Encodes value into output starting at index without bounds
checks.
§Parameters
value: Value to encode.output: Destination byte buffer.index: Start index inoutput.
§Returns
Returns the number of written bytes.
§Safety
The caller must guarantee that output.as_mut_ptr().add(index)
is valid to write Self::MAX_UNITS_PER_VALUE bytes.
Source§impl<P> Leb128Codec<u64, P>where
P: Leb128DecodePolicy,
impl<P> Leb128Codec<u64, P>where
P: Leb128DecodePolicy,
Sourcepub const MIN_UNITS_PER_VALUE: usize = 1
pub const MIN_UNITS_PER_VALUE: usize = 1
Minimum number of bytes that can represent a complete value.
Sourcepub const MAX_UNITS_PER_VALUE: usize
pub const MAX_UNITS_PER_VALUE: usize
Maximum number of bytes required to encode or decode this type.
Sourcepub unsafe fn decode_unchecked(
input: &[u8],
index: usize,
) -> Result<(u64, NonZeroUsize), Leb128DecodeError>
pub unsafe fn decode_unchecked( input: &[u8], index: usize, ) -> Result<(u64, NonZeroUsize), Leb128DecodeError>
Decodes a value from input starting at index without bounds
checks.
§Parameters
input: Source byte buffer.index: Start index ininput.
§Returns
Returns the decoded value and the non-zero number of consumed bytes.
§Errors
Returns Leb128DecodeError if the bytes are incomplete,
malformed, or strict decoding rejects a non-canonical
representation.
§Safety
The caller must guarantee that index is a valid boundary and
at least Self::MIN_UNITS_PER_VALUE byte is readable from
index.
Sourcepub unsafe fn encode_unchecked(
value: u64,
output: &mut [u8],
index: usize,
) -> usize
pub unsafe fn encode_unchecked( value: u64, output: &mut [u8], index: usize, ) -> usize
Encodes value into output starting at index without bounds
checks.
§Parameters
value: Value to encode.output: Destination byte buffer.index: Start index inoutput.
§Returns
Returns the number of written bytes.
§Safety
The caller must guarantee that output.as_mut_ptr().add(index)
is valid to write Self::MAX_UNITS_PER_VALUE bytes.
Source§impl<P> Leb128Codec<u128, P>where
P: Leb128DecodePolicy,
impl<P> Leb128Codec<u128, P>where
P: Leb128DecodePolicy,
Sourcepub const MIN_UNITS_PER_VALUE: usize = 1
pub const MIN_UNITS_PER_VALUE: usize = 1
Minimum number of bytes that can represent a complete value.
Sourcepub const MAX_UNITS_PER_VALUE: usize
pub const MAX_UNITS_PER_VALUE: usize
Maximum number of bytes required to encode or decode this type.
Sourcepub unsafe fn decode_unchecked(
input: &[u8],
index: usize,
) -> Result<(u128, NonZeroUsize), Leb128DecodeError>
pub unsafe fn decode_unchecked( input: &[u8], index: usize, ) -> Result<(u128, NonZeroUsize), Leb128DecodeError>
Decodes a value from input starting at index without bounds
checks.
§Parameters
input: Source byte buffer.index: Start index ininput.
§Returns
Returns the decoded value and the non-zero number of consumed bytes.
§Errors
Returns Leb128DecodeError if the bytes are incomplete,
malformed, or strict decoding rejects a non-canonical
representation.
§Safety
The caller must guarantee that index is a valid boundary and
at least Self::MIN_UNITS_PER_VALUE byte is readable from
index.
Sourcepub unsafe fn encode_unchecked(
value: u128,
output: &mut [u8],
index: usize,
) -> usize
pub unsafe fn encode_unchecked( value: u128, output: &mut [u8], index: usize, ) -> usize
Encodes value into output starting at index without bounds
checks.
§Parameters
value: Value to encode.output: Destination byte buffer.index: Start index inoutput.
§Returns
Returns the number of written bytes.
§Safety
The caller must guarantee that output.as_mut_ptr().add(index)
is valid to write Self::MAX_UNITS_PER_VALUE bytes.
Source§impl<P> Leb128Codec<usize, P>where
P: Leb128DecodePolicy,
impl<P> Leb128Codec<usize, P>where
P: Leb128DecodePolicy,
Sourcepub const MIN_UNITS_PER_VALUE: usize = 1
pub const MIN_UNITS_PER_VALUE: usize = 1
Minimum number of bytes that can represent a complete value.
Sourcepub const MAX_UNITS_PER_VALUE: usize
pub const MAX_UNITS_PER_VALUE: usize
Maximum number of bytes required to encode or decode this type.
Sourcepub unsafe fn decode_unchecked(
input: &[u8],
index: usize,
) -> Result<(usize, NonZeroUsize), Leb128DecodeError>
pub unsafe fn decode_unchecked( input: &[u8], index: usize, ) -> Result<(usize, NonZeroUsize), Leb128DecodeError>
Decodes a value from input starting at index without bounds
checks.
§Parameters
input: Source byte buffer.index: Start index ininput.
§Returns
Returns the decoded value and the non-zero number of consumed bytes.
§Errors
Returns Leb128DecodeError if the bytes are incomplete,
malformed, or strict decoding rejects a non-canonical
representation.
§Safety
The caller must guarantee that index is a valid boundary and
at least Self::MIN_UNITS_PER_VALUE byte is readable from
index.
Sourcepub unsafe fn encode_unchecked(
value: usize,
output: &mut [u8],
index: usize,
) -> usize
pub unsafe fn encode_unchecked( value: usize, output: &mut [u8], index: usize, ) -> usize
Encodes value into output starting at index without bounds
checks.
§Parameters
value: Value to encode.output: Destination byte buffer.index: Start index inoutput.
§Returns
Returns the number of written bytes.
§Safety
The caller must guarantee that output.as_mut_ptr().add(index)
is valid to write Self::MAX_UNITS_PER_VALUE bytes.
Source§impl<P> Leb128Codec<i8, P>where
P: Leb128DecodePolicy,
impl<P> Leb128Codec<i8, P>where
P: Leb128DecodePolicy,
Sourcepub const MIN_UNITS_PER_VALUE: usize = 1
pub const MIN_UNITS_PER_VALUE: usize = 1
Minimum number of bytes that can represent a complete value.
Sourcepub const MAX_UNITS_PER_VALUE: usize
pub const MAX_UNITS_PER_VALUE: usize
Maximum number of bytes required to encode or decode this type.
Sourcepub unsafe fn decode_unchecked(
input: &[u8],
index: usize,
) -> Result<(i8, NonZeroUsize), Leb128DecodeError>
pub unsafe fn decode_unchecked( input: &[u8], index: usize, ) -> Result<(i8, NonZeroUsize), Leb128DecodeError>
Decodes a value from input starting at index without bounds
checks.
§Parameters
input: Source byte buffer.index: Start index ininput.
§Returns
Returns the decoded value and the non-zero number of consumed bytes.
§Errors
Returns Leb128DecodeError if the bytes are incomplete,
malformed, or strict decoding rejects a non-canonical
representation.
§Safety
The caller must guarantee that index is a valid boundary and
at least Self::MIN_UNITS_PER_VALUE byte is readable from
index.
Sourcepub unsafe fn encode_unchecked(
value: i8,
output: &mut [u8],
index: usize,
) -> usize
pub unsafe fn encode_unchecked( value: i8, output: &mut [u8], index: usize, ) -> usize
Encodes value into output starting at index without bounds
checks.
§Parameters
value: Value to encode.output: Destination byte buffer.index: Start index inoutput.
§Returns
Returns the number of written bytes.
§Safety
The caller must guarantee that output.as_mut_ptr().add(index)
is valid to write Self::MAX_UNITS_PER_VALUE bytes.
Source§impl<P> Leb128Codec<i16, P>where
P: Leb128DecodePolicy,
impl<P> Leb128Codec<i16, P>where
P: Leb128DecodePolicy,
Sourcepub const MIN_UNITS_PER_VALUE: usize = 1
pub const MIN_UNITS_PER_VALUE: usize = 1
Minimum number of bytes that can represent a complete value.
Sourcepub const MAX_UNITS_PER_VALUE: usize
pub const MAX_UNITS_PER_VALUE: usize
Maximum number of bytes required to encode or decode this type.
Sourcepub unsafe fn decode_unchecked(
input: &[u8],
index: usize,
) -> Result<(i16, NonZeroUsize), Leb128DecodeError>
pub unsafe fn decode_unchecked( input: &[u8], index: usize, ) -> Result<(i16, NonZeroUsize), Leb128DecodeError>
Decodes a value from input starting at index without bounds
checks.
§Parameters
input: Source byte buffer.index: Start index ininput.
§Returns
Returns the decoded value and the non-zero number of consumed bytes.
§Errors
Returns Leb128DecodeError if the bytes are incomplete,
malformed, or strict decoding rejects a non-canonical
representation.
§Safety
The caller must guarantee that index is a valid boundary and
at least Self::MIN_UNITS_PER_VALUE byte is readable from
index.
Sourcepub unsafe fn encode_unchecked(
value: i16,
output: &mut [u8],
index: usize,
) -> usize
pub unsafe fn encode_unchecked( value: i16, output: &mut [u8], index: usize, ) -> usize
Encodes value into output starting at index without bounds
checks.
§Parameters
value: Value to encode.output: Destination byte buffer.index: Start index inoutput.
§Returns
Returns the number of written bytes.
§Safety
The caller must guarantee that output.as_mut_ptr().add(index)
is valid to write Self::MAX_UNITS_PER_VALUE bytes.
Source§impl<P> Leb128Codec<i32, P>where
P: Leb128DecodePolicy,
impl<P> Leb128Codec<i32, P>where
P: Leb128DecodePolicy,
Sourcepub const MIN_UNITS_PER_VALUE: usize = 1
pub const MIN_UNITS_PER_VALUE: usize = 1
Minimum number of bytes that can represent a complete value.
Sourcepub const MAX_UNITS_PER_VALUE: usize
pub const MAX_UNITS_PER_VALUE: usize
Maximum number of bytes required to encode or decode this type.
Sourcepub unsafe fn decode_unchecked(
input: &[u8],
index: usize,
) -> Result<(i32, NonZeroUsize), Leb128DecodeError>
pub unsafe fn decode_unchecked( input: &[u8], index: usize, ) -> Result<(i32, NonZeroUsize), Leb128DecodeError>
Decodes a value from input starting at index without bounds
checks.
§Parameters
input: Source byte buffer.index: Start index ininput.
§Returns
Returns the decoded value and the non-zero number of consumed bytes.
§Errors
Returns Leb128DecodeError if the bytes are incomplete,
malformed, or strict decoding rejects a non-canonical
representation.
§Safety
The caller must guarantee that index is a valid boundary and
at least Self::MIN_UNITS_PER_VALUE byte is readable from
index.
Sourcepub unsafe fn encode_unchecked(
value: i32,
output: &mut [u8],
index: usize,
) -> usize
pub unsafe fn encode_unchecked( value: i32, output: &mut [u8], index: usize, ) -> usize
Encodes value into output starting at index without bounds
checks.
§Parameters
value: Value to encode.output: Destination byte buffer.index: Start index inoutput.
§Returns
Returns the number of written bytes.
§Safety
The caller must guarantee that output.as_mut_ptr().add(index)
is valid to write Self::MAX_UNITS_PER_VALUE bytes.
Source§impl<P> Leb128Codec<i64, P>where
P: Leb128DecodePolicy,
impl<P> Leb128Codec<i64, P>where
P: Leb128DecodePolicy,
Sourcepub const MIN_UNITS_PER_VALUE: usize = 1
pub const MIN_UNITS_PER_VALUE: usize = 1
Minimum number of bytes that can represent a complete value.
Sourcepub const MAX_UNITS_PER_VALUE: usize
pub const MAX_UNITS_PER_VALUE: usize
Maximum number of bytes required to encode or decode this type.
Sourcepub unsafe fn decode_unchecked(
input: &[u8],
index: usize,
) -> Result<(i64, NonZeroUsize), Leb128DecodeError>
pub unsafe fn decode_unchecked( input: &[u8], index: usize, ) -> Result<(i64, NonZeroUsize), Leb128DecodeError>
Decodes a value from input starting at index without bounds
checks.
§Parameters
input: Source byte buffer.index: Start index ininput.
§Returns
Returns the decoded value and the non-zero number of consumed bytes.
§Errors
Returns Leb128DecodeError if the bytes are incomplete,
malformed, or strict decoding rejects a non-canonical
representation.
§Safety
The caller must guarantee that index is a valid boundary and
at least Self::MIN_UNITS_PER_VALUE byte is readable from
index.
Sourcepub unsafe fn encode_unchecked(
value: i64,
output: &mut [u8],
index: usize,
) -> usize
pub unsafe fn encode_unchecked( value: i64, output: &mut [u8], index: usize, ) -> usize
Encodes value into output starting at index without bounds
checks.
§Parameters
value: Value to encode.output: Destination byte buffer.index: Start index inoutput.
§Returns
Returns the number of written bytes.
§Safety
The caller must guarantee that output.as_mut_ptr().add(index)
is valid to write Self::MAX_UNITS_PER_VALUE bytes.
Source§impl<P> Leb128Codec<i128, P>where
P: Leb128DecodePolicy,
impl<P> Leb128Codec<i128, P>where
P: Leb128DecodePolicy,
Sourcepub const MIN_UNITS_PER_VALUE: usize = 1
pub const MIN_UNITS_PER_VALUE: usize = 1
Minimum number of bytes that can represent a complete value.
Sourcepub const MAX_UNITS_PER_VALUE: usize
pub const MAX_UNITS_PER_VALUE: usize
Maximum number of bytes required to encode or decode this type.
Sourcepub unsafe fn decode_unchecked(
input: &[u8],
index: usize,
) -> Result<(i128, NonZeroUsize), Leb128DecodeError>
pub unsafe fn decode_unchecked( input: &[u8], index: usize, ) -> Result<(i128, NonZeroUsize), Leb128DecodeError>
Decodes a value from input starting at index without bounds
checks.
§Parameters
input: Source byte buffer.index: Start index ininput.
§Returns
Returns the decoded value and the non-zero number of consumed bytes.
§Errors
Returns Leb128DecodeError if the bytes are incomplete,
malformed, or strict decoding rejects a non-canonical
representation.
§Safety
The caller must guarantee that index is a valid boundary and
at least Self::MIN_UNITS_PER_VALUE byte is readable from
index.
Sourcepub unsafe fn encode_unchecked(
value: i128,
output: &mut [u8],
index: usize,
) -> usize
pub unsafe fn encode_unchecked( value: i128, output: &mut [u8], index: usize, ) -> usize
Encodes value into output starting at index without bounds
checks.
§Parameters
value: Value to encode.output: Destination byte buffer.index: Start index inoutput.
§Returns
Returns the number of written bytes.
§Safety
The caller must guarantee that output.as_mut_ptr().add(index)
is valid to write Self::MAX_UNITS_PER_VALUE bytes.
Source§impl<P> Leb128Codec<isize, P>where
P: Leb128DecodePolicy,
impl<P> Leb128Codec<isize, P>where
P: Leb128DecodePolicy,
Sourcepub const MIN_UNITS_PER_VALUE: usize = 1
pub const MIN_UNITS_PER_VALUE: usize = 1
Minimum number of bytes that can represent a complete value.
Sourcepub const MAX_UNITS_PER_VALUE: usize
pub const MAX_UNITS_PER_VALUE: usize
Maximum number of bytes required to encode or decode this type.
Sourcepub unsafe fn decode_unchecked(
input: &[u8],
index: usize,
) -> Result<(isize, NonZeroUsize), Leb128DecodeError>
pub unsafe fn decode_unchecked( input: &[u8], index: usize, ) -> Result<(isize, NonZeroUsize), Leb128DecodeError>
Decodes a value from input starting at index without bounds
checks.
§Parameters
input: Source byte buffer.index: Start index ininput.
§Returns
Returns the decoded value and the non-zero number of consumed bytes.
§Errors
Returns Leb128DecodeError if the bytes are incomplete,
malformed, or strict decoding rejects a non-canonical
representation.
§Safety
The caller must guarantee that index is a valid boundary and
at least Self::MIN_UNITS_PER_VALUE byte is readable from
index.
Sourcepub unsafe fn encode_unchecked(
value: isize,
output: &mut [u8],
index: usize,
) -> usize
pub unsafe fn encode_unchecked( value: isize, output: &mut [u8], index: usize, ) -> usize
Encodes value into output starting at index without bounds
checks.
§Parameters
value: Value to encode.output: Destination byte buffer.index: Start index inoutput.
§Returns
Returns the number of written bytes.
§Safety
The caller must guarantee that output.as_mut_ptr().add(index)
is valid to write Self::MAX_UNITS_PER_VALUE bytes.
Trait Implementations§
Source§impl<T: Clone, P: Clone> Clone for Leb128Codec<T, P>
impl<T: Clone, P: Clone> Clone for Leb128Codec<T, P>
Source§fn clone(&self) -> Leb128Codec<T, P>
fn clone(&self) -> Leb128Codec<T, P>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<P> Codec for Leb128Codec<i128, P>where
P: Leb128DecodePolicy,
impl<P> Codec for Leb128Codec<i128, P>where
P: Leb128DecodePolicy,
Source§type DecodeError = Leb128DecodeError
type DecodeError = Leb128DecodeError
Source§type EncodeError = Infallible
type EncodeError = Infallible
Source§fn min_units_per_value(&self) -> NonZeroUsize
fn min_units_per_value(&self) -> NonZeroUsize
Source§fn max_units_per_value(&self) -> NonZeroUsize
fn max_units_per_value(&self) -> NonZeroUsize
Source§unsafe fn decode_unchecked(
&self,
input: &[u8],
index: usize,
) -> Result<(i128, NonZeroUsize), Self::DecodeError>
unsafe fn decode_unchecked( &self, input: &[u8], index: usize, ) -> Result<(i128, NonZeroUsize), Self::DecodeError>
Source§unsafe fn encode_unchecked(
&self,
value: &i128,
output: &mut [u8],
index: usize,
) -> Result<usize, Self::EncodeError>
unsafe fn encode_unchecked( &self, value: &i128, output: &mut [u8], index: usize, ) -> Result<usize, Self::EncodeError>
Source§impl<P> Codec for Leb128Codec<i16, P>where
P: Leb128DecodePolicy,
impl<P> Codec for Leb128Codec<i16, P>where
P: Leb128DecodePolicy,
Source§type DecodeError = Leb128DecodeError
type DecodeError = Leb128DecodeError
Source§type EncodeError = Infallible
type EncodeError = Infallible
Source§fn min_units_per_value(&self) -> NonZeroUsize
fn min_units_per_value(&self) -> NonZeroUsize
Source§fn max_units_per_value(&self) -> NonZeroUsize
fn max_units_per_value(&self) -> NonZeroUsize
Source§unsafe fn decode_unchecked(
&self,
input: &[u8],
index: usize,
) -> Result<(i16, NonZeroUsize), Self::DecodeError>
unsafe fn decode_unchecked( &self, input: &[u8], index: usize, ) -> Result<(i16, NonZeroUsize), Self::DecodeError>
Source§unsafe fn encode_unchecked(
&self,
value: &i16,
output: &mut [u8],
index: usize,
) -> Result<usize, Self::EncodeError>
unsafe fn encode_unchecked( &self, value: &i16, output: &mut [u8], index: usize, ) -> Result<usize, Self::EncodeError>
Source§impl<P> Codec for Leb128Codec<i32, P>where
P: Leb128DecodePolicy,
impl<P> Codec for Leb128Codec<i32, P>where
P: Leb128DecodePolicy,
Source§type DecodeError = Leb128DecodeError
type DecodeError = Leb128DecodeError
Source§type EncodeError = Infallible
type EncodeError = Infallible
Source§fn min_units_per_value(&self) -> NonZeroUsize
fn min_units_per_value(&self) -> NonZeroUsize
Source§fn max_units_per_value(&self) -> NonZeroUsize
fn max_units_per_value(&self) -> NonZeroUsize
Source§unsafe fn decode_unchecked(
&self,
input: &[u8],
index: usize,
) -> Result<(i32, NonZeroUsize), Self::DecodeError>
unsafe fn decode_unchecked( &self, input: &[u8], index: usize, ) -> Result<(i32, NonZeroUsize), Self::DecodeError>
Source§unsafe fn encode_unchecked(
&self,
value: &i32,
output: &mut [u8],
index: usize,
) -> Result<usize, Self::EncodeError>
unsafe fn encode_unchecked( &self, value: &i32, output: &mut [u8], index: usize, ) -> Result<usize, Self::EncodeError>
Source§impl<P> Codec for Leb128Codec<i64, P>where
P: Leb128DecodePolicy,
impl<P> Codec for Leb128Codec<i64, P>where
P: Leb128DecodePolicy,
Source§type DecodeError = Leb128DecodeError
type DecodeError = Leb128DecodeError
Source§type EncodeError = Infallible
type EncodeError = Infallible
Source§fn min_units_per_value(&self) -> NonZeroUsize
fn min_units_per_value(&self) -> NonZeroUsize
Source§fn max_units_per_value(&self) -> NonZeroUsize
fn max_units_per_value(&self) -> NonZeroUsize
Source§unsafe fn decode_unchecked(
&self,
input: &[u8],
index: usize,
) -> Result<(i64, NonZeroUsize), Self::DecodeError>
unsafe fn decode_unchecked( &self, input: &[u8], index: usize, ) -> Result<(i64, NonZeroUsize), Self::DecodeError>
Source§unsafe fn encode_unchecked(
&self,
value: &i64,
output: &mut [u8],
index: usize,
) -> Result<usize, Self::EncodeError>
unsafe fn encode_unchecked( &self, value: &i64, output: &mut [u8], index: usize, ) -> Result<usize, Self::EncodeError>
Source§impl<P> Codec for Leb128Codec<i8, P>where
P: Leb128DecodePolicy,
impl<P> Codec for Leb128Codec<i8, P>where
P: Leb128DecodePolicy,
Source§type DecodeError = Leb128DecodeError
type DecodeError = Leb128DecodeError
Source§type EncodeError = Infallible
type EncodeError = Infallible
Source§fn min_units_per_value(&self) -> NonZeroUsize
fn min_units_per_value(&self) -> NonZeroUsize
Source§fn max_units_per_value(&self) -> NonZeroUsize
fn max_units_per_value(&self) -> NonZeroUsize
Source§unsafe fn decode_unchecked(
&self,
input: &[u8],
index: usize,
) -> Result<(i8, NonZeroUsize), Self::DecodeError>
unsafe fn decode_unchecked( &self, input: &[u8], index: usize, ) -> Result<(i8, NonZeroUsize), Self::DecodeError>
Source§unsafe fn encode_unchecked(
&self,
value: &i8,
output: &mut [u8],
index: usize,
) -> Result<usize, Self::EncodeError>
unsafe fn encode_unchecked( &self, value: &i8, output: &mut [u8], index: usize, ) -> Result<usize, Self::EncodeError>
Source§impl<P> Codec for Leb128Codec<isize, P>where
P: Leb128DecodePolicy,
impl<P> Codec for Leb128Codec<isize, P>where
P: Leb128DecodePolicy,
Source§type DecodeError = Leb128DecodeError
type DecodeError = Leb128DecodeError
Source§type EncodeError = Infallible
type EncodeError = Infallible
Source§fn min_units_per_value(&self) -> NonZeroUsize
fn min_units_per_value(&self) -> NonZeroUsize
Source§fn max_units_per_value(&self) -> NonZeroUsize
fn max_units_per_value(&self) -> NonZeroUsize
Source§unsafe fn decode_unchecked(
&self,
input: &[u8],
index: usize,
) -> Result<(isize, NonZeroUsize), Self::DecodeError>
unsafe fn decode_unchecked( &self, input: &[u8], index: usize, ) -> Result<(isize, NonZeroUsize), Self::DecodeError>
Source§unsafe fn encode_unchecked(
&self,
value: &isize,
output: &mut [u8],
index: usize,
) -> Result<usize, Self::EncodeError>
unsafe fn encode_unchecked( &self, value: &isize, output: &mut [u8], index: usize, ) -> Result<usize, Self::EncodeError>
Source§impl<P> Codec for Leb128Codec<u128, P>where
P: Leb128DecodePolicy,
impl<P> Codec for Leb128Codec<u128, P>where
P: Leb128DecodePolicy,
Source§type DecodeError = Leb128DecodeError
type DecodeError = Leb128DecodeError
Source§type EncodeError = Infallible
type EncodeError = Infallible
Source§fn min_units_per_value(&self) -> NonZeroUsize
fn min_units_per_value(&self) -> NonZeroUsize
Source§fn max_units_per_value(&self) -> NonZeroUsize
fn max_units_per_value(&self) -> NonZeroUsize
Source§unsafe fn decode_unchecked(
&self,
input: &[u8],
index: usize,
) -> Result<(u128, NonZeroUsize), Self::DecodeError>
unsafe fn decode_unchecked( &self, input: &[u8], index: usize, ) -> Result<(u128, NonZeroUsize), Self::DecodeError>
Source§unsafe fn encode_unchecked(
&self,
value: &u128,
output: &mut [u8],
index: usize,
) -> Result<usize, Self::EncodeError>
unsafe fn encode_unchecked( &self, value: &u128, output: &mut [u8], index: usize, ) -> Result<usize, Self::EncodeError>
Source§impl<P> Codec for Leb128Codec<u16, P>where
P: Leb128DecodePolicy,
impl<P> Codec for Leb128Codec<u16, P>where
P: Leb128DecodePolicy,
Source§type DecodeError = Leb128DecodeError
type DecodeError = Leb128DecodeError
Source§type EncodeError = Infallible
type EncodeError = Infallible
Source§fn min_units_per_value(&self) -> NonZeroUsize
fn min_units_per_value(&self) -> NonZeroUsize
Source§fn max_units_per_value(&self) -> NonZeroUsize
fn max_units_per_value(&self) -> NonZeroUsize
Source§unsafe fn decode_unchecked(
&self,
input: &[u8],
index: usize,
) -> Result<(u16, NonZeroUsize), Self::DecodeError>
unsafe fn decode_unchecked( &self, input: &[u8], index: usize, ) -> Result<(u16, NonZeroUsize), Self::DecodeError>
Source§unsafe fn encode_unchecked(
&self,
value: &u16,
output: &mut [u8],
index: usize,
) -> Result<usize, Self::EncodeError>
unsafe fn encode_unchecked( &self, value: &u16, output: &mut [u8], index: usize, ) -> Result<usize, Self::EncodeError>
Source§impl<P> Codec for Leb128Codec<u32, P>where
P: Leb128DecodePolicy,
impl<P> Codec for Leb128Codec<u32, P>where
P: Leb128DecodePolicy,
Source§type DecodeError = Leb128DecodeError
type DecodeError = Leb128DecodeError
Source§type EncodeError = Infallible
type EncodeError = Infallible
Source§fn min_units_per_value(&self) -> NonZeroUsize
fn min_units_per_value(&self) -> NonZeroUsize
Source§fn max_units_per_value(&self) -> NonZeroUsize
fn max_units_per_value(&self) -> NonZeroUsize
Source§unsafe fn decode_unchecked(
&self,
input: &[u8],
index: usize,
) -> Result<(u32, NonZeroUsize), Self::DecodeError>
unsafe fn decode_unchecked( &self, input: &[u8], index: usize, ) -> Result<(u32, NonZeroUsize), Self::DecodeError>
Source§unsafe fn encode_unchecked(
&self,
value: &u32,
output: &mut [u8],
index: usize,
) -> Result<usize, Self::EncodeError>
unsafe fn encode_unchecked( &self, value: &u32, output: &mut [u8], index: usize, ) -> Result<usize, Self::EncodeError>
Source§impl<P> Codec for Leb128Codec<u64, P>where
P: Leb128DecodePolicy,
impl<P> Codec for Leb128Codec<u64, P>where
P: Leb128DecodePolicy,
Source§type DecodeError = Leb128DecodeError
type DecodeError = Leb128DecodeError
Source§type EncodeError = Infallible
type EncodeError = Infallible
Source§fn min_units_per_value(&self) -> NonZeroUsize
fn min_units_per_value(&self) -> NonZeroUsize
Source§fn max_units_per_value(&self) -> NonZeroUsize
fn max_units_per_value(&self) -> NonZeroUsize
Source§unsafe fn decode_unchecked(
&self,
input: &[u8],
index: usize,
) -> Result<(u64, NonZeroUsize), Self::DecodeError>
unsafe fn decode_unchecked( &self, input: &[u8], index: usize, ) -> Result<(u64, NonZeroUsize), Self::DecodeError>
Source§unsafe fn encode_unchecked(
&self,
value: &u64,
output: &mut [u8],
index: usize,
) -> Result<usize, Self::EncodeError>
unsafe fn encode_unchecked( &self, value: &u64, output: &mut [u8], index: usize, ) -> Result<usize, Self::EncodeError>
Source§impl<P> Codec for Leb128Codec<u8, P>where
P: Leb128DecodePolicy,
impl<P> Codec for Leb128Codec<u8, P>where
P: Leb128DecodePolicy,
Source§type DecodeError = Leb128DecodeError
type DecodeError = Leb128DecodeError
Source§type EncodeError = Infallible
type EncodeError = Infallible
Source§fn min_units_per_value(&self) -> NonZeroUsize
fn min_units_per_value(&self) -> NonZeroUsize
Source§fn max_units_per_value(&self) -> NonZeroUsize
fn max_units_per_value(&self) -> NonZeroUsize
Source§unsafe fn decode_unchecked(
&self,
input: &[u8],
index: usize,
) -> Result<(u8, NonZeroUsize), Self::DecodeError>
unsafe fn decode_unchecked( &self, input: &[u8], index: usize, ) -> Result<(u8, NonZeroUsize), Self::DecodeError>
Source§unsafe fn encode_unchecked(
&self,
value: &u8,
output: &mut [u8],
index: usize,
) -> Result<usize, Self::EncodeError>
unsafe fn encode_unchecked( &self, value: &u8, output: &mut [u8], index: usize, ) -> Result<usize, Self::EncodeError>
Source§impl<P> Codec for Leb128Codec<usize, P>where
P: Leb128DecodePolicy,
impl<P> Codec for Leb128Codec<usize, P>where
P: Leb128DecodePolicy,
Source§type DecodeError = Leb128DecodeError
type DecodeError = Leb128DecodeError
Source§type EncodeError = Infallible
type EncodeError = Infallible
Source§fn min_units_per_value(&self) -> NonZeroUsize
fn min_units_per_value(&self) -> NonZeroUsize
Source§fn max_units_per_value(&self) -> NonZeroUsize
fn max_units_per_value(&self) -> NonZeroUsize
Source§unsafe fn decode_unchecked(
&self,
input: &[u8],
index: usize,
) -> Result<(usize, NonZeroUsize), Self::DecodeError>
unsafe fn decode_unchecked( &self, input: &[u8], index: usize, ) -> Result<(usize, NonZeroUsize), Self::DecodeError>
Source§unsafe fn encode_unchecked(
&self,
value: &usize,
output: &mut [u8],
index: usize,
) -> Result<usize, Self::EncodeError>
unsafe fn encode_unchecked( &self, value: &usize, output: &mut [u8], index: usize, ) -> Result<usize, Self::EncodeError>
impl<T: Copy, P: Copy> Copy for Leb128Codec<T, P>
Source§impl<T: Default, P: Default> Default for Leb128Codec<T, P>
impl<T: Default, P: Default> Default for Leb128Codec<T, P>
Source§fn default() -> Leb128Codec<T, P>
fn default() -> Leb128Codec<T, P>
impl<T: Eq, P: Eq> Eq for Leb128Codec<T, P>
Source§impl<T: PartialEq, P: PartialEq> PartialEq for Leb128Codec<T, P>
impl<T: PartialEq, P: PartialEq> PartialEq for Leb128Codec<T, P>
Source§fn eq(&self, other: &Leb128Codec<T, P>) -> bool
fn eq(&self, other: &Leb128Codec<T, P>) -> bool
self and other values to be equal, and is used by ==.