pub struct ZigZagCodec<T, P = NonStrict> { /* private fields */ }Expand description
Type-level unchecked ZigZag + unsigned LEB128 codec.
T selects the signed integer type and P selects the LEB128 decoding
policy used after ZigZag conversion.
Implementations§
Source§impl<P> ZigZagCodec<i8, P>where
P: DecodePolicy,
impl<P> ZigZagCodec<i8, P>where
P: DecodePolicy,
Sourcepub const REQUIRED_MIN_BUFFER_LEN: usize = Leb128Codec<u8, NonStrict>::REQUIRED_MIN_BUFFER_LEN
pub const REQUIRED_MIN_BUFFER_LEN: usize = Leb128Codec<u8, NonStrict>::REQUIRED_MIN_BUFFER_LEN
Minimum number of bytes required to encode or decode this type.
Sourcepub unsafe fn read_unchecked(
input: &[u8],
index: usize,
) -> Result<(i8, usize), Leb128DecodeError>
pub unsafe fn read_unchecked( input: &[u8], index: usize, ) -> Result<(i8, usize), 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 number of consumed bytes.
§Errors
Returns Leb128DecodeError if the underlying LEB128 bytes are invalid.
§Safety
The caller must guarantee that input.as_ptr().add(index) is valid to
read Self::REQUIRED_MIN_BUFFER_LEN bytes, or that a valid terminating byte
appears before that limit.
Sourcepub unsafe fn write_unchecked(
output: &mut [u8],
index: usize,
value: i8,
) -> usize
pub unsafe fn write_unchecked( output: &mut [u8], index: usize, value: i8, ) -> usize
Encodes value into output starting at index without bounds checks.
§Parameters
output: Destination byte buffer.index: Start index inoutput.value: Value to encode.
§Returns
Returns the number of written bytes.
§Safety
The caller must guarantee that output.as_mut_ptr().add(index) is valid
to write Self::REQUIRED_MIN_BUFFER_LEN bytes.
Source§impl<P> ZigZagCodec<i16, P>where
P: DecodePolicy,
impl<P> ZigZagCodec<i16, P>where
P: DecodePolicy,
Sourcepub const REQUIRED_MIN_BUFFER_LEN: usize = Leb128Codec<u16, NonStrict>::REQUIRED_MIN_BUFFER_LEN
pub const REQUIRED_MIN_BUFFER_LEN: usize = Leb128Codec<u16, NonStrict>::REQUIRED_MIN_BUFFER_LEN
Minimum number of bytes required to encode or decode this type.
Sourcepub unsafe fn read_unchecked(
input: &[u8],
index: usize,
) -> Result<(i16, usize), Leb128DecodeError>
pub unsafe fn read_unchecked( input: &[u8], index: usize, ) -> Result<(i16, usize), 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 number of consumed bytes.
§Errors
Returns Leb128DecodeError if the underlying LEB128 bytes are invalid.
§Safety
The caller must guarantee that input.as_ptr().add(index) is valid to
read Self::REQUIRED_MIN_BUFFER_LEN bytes, or that a valid terminating byte
appears before that limit.
Sourcepub unsafe fn write_unchecked(
output: &mut [u8],
index: usize,
value: i16,
) -> usize
pub unsafe fn write_unchecked( output: &mut [u8], index: usize, value: i16, ) -> usize
Encodes value into output starting at index without bounds checks.
§Parameters
output: Destination byte buffer.index: Start index inoutput.value: Value to encode.
§Returns
Returns the number of written bytes.
§Safety
The caller must guarantee that output.as_mut_ptr().add(index) is valid
to write Self::REQUIRED_MIN_BUFFER_LEN bytes.
Source§impl<P> ZigZagCodec<i32, P>where
P: DecodePolicy,
impl<P> ZigZagCodec<i32, P>where
P: DecodePolicy,
Sourcepub const REQUIRED_MIN_BUFFER_LEN: usize = Leb128Codec<u32, NonStrict>::REQUIRED_MIN_BUFFER_LEN
pub const REQUIRED_MIN_BUFFER_LEN: usize = Leb128Codec<u32, NonStrict>::REQUIRED_MIN_BUFFER_LEN
Minimum number of bytes required to encode or decode this type.
Sourcepub unsafe fn read_unchecked(
input: &[u8],
index: usize,
) -> Result<(i32, usize), Leb128DecodeError>
pub unsafe fn read_unchecked( input: &[u8], index: usize, ) -> Result<(i32, usize), 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 number of consumed bytes.
§Errors
Returns Leb128DecodeError if the underlying LEB128 bytes are invalid.
§Safety
The caller must guarantee that input.as_ptr().add(index) is valid to
read Self::REQUIRED_MIN_BUFFER_LEN bytes, or that a valid terminating byte
appears before that limit.
Sourcepub unsafe fn write_unchecked(
output: &mut [u8],
index: usize,
value: i32,
) -> usize
pub unsafe fn write_unchecked( output: &mut [u8], index: usize, value: i32, ) -> usize
Encodes value into output starting at index without bounds checks.
§Parameters
output: Destination byte buffer.index: Start index inoutput.value: Value to encode.
§Returns
Returns the number of written bytes.
§Safety
The caller must guarantee that output.as_mut_ptr().add(index) is valid
to write Self::REQUIRED_MIN_BUFFER_LEN bytes.
Source§impl<P> ZigZagCodec<i64, P>where
P: DecodePolicy,
impl<P> ZigZagCodec<i64, P>where
P: DecodePolicy,
Sourcepub const REQUIRED_MIN_BUFFER_LEN: usize = Leb128Codec<u64, NonStrict>::REQUIRED_MIN_BUFFER_LEN
pub const REQUIRED_MIN_BUFFER_LEN: usize = Leb128Codec<u64, NonStrict>::REQUIRED_MIN_BUFFER_LEN
Minimum number of bytes required to encode or decode this type.
Sourcepub unsafe fn read_unchecked(
input: &[u8],
index: usize,
) -> Result<(i64, usize), Leb128DecodeError>
pub unsafe fn read_unchecked( input: &[u8], index: usize, ) -> Result<(i64, usize), 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 number of consumed bytes.
§Errors
Returns Leb128DecodeError if the underlying LEB128 bytes are invalid.
§Safety
The caller must guarantee that input.as_ptr().add(index) is valid to
read Self::REQUIRED_MIN_BUFFER_LEN bytes, or that a valid terminating byte
appears before that limit.
Sourcepub unsafe fn write_unchecked(
output: &mut [u8],
index: usize,
value: i64,
) -> usize
pub unsafe fn write_unchecked( output: &mut [u8], index: usize, value: i64, ) -> usize
Encodes value into output starting at index without bounds checks.
§Parameters
output: Destination byte buffer.index: Start index inoutput.value: Value to encode.
§Returns
Returns the number of written bytes.
§Safety
The caller must guarantee that output.as_mut_ptr().add(index) is valid
to write Self::REQUIRED_MIN_BUFFER_LEN bytes.
Source§impl<P> ZigZagCodec<i128, P>where
P: DecodePolicy,
impl<P> ZigZagCodec<i128, P>where
P: DecodePolicy,
Sourcepub const REQUIRED_MIN_BUFFER_LEN: usize = Leb128Codec<u128, NonStrict>::REQUIRED_MIN_BUFFER_LEN
pub const REQUIRED_MIN_BUFFER_LEN: usize = Leb128Codec<u128, NonStrict>::REQUIRED_MIN_BUFFER_LEN
Minimum number of bytes required to encode or decode this type.
Sourcepub unsafe fn read_unchecked(
input: &[u8],
index: usize,
) -> Result<(i128, usize), Leb128DecodeError>
pub unsafe fn read_unchecked( input: &[u8], index: usize, ) -> Result<(i128, usize), 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 number of consumed bytes.
§Errors
Returns Leb128DecodeError if the underlying LEB128 bytes are invalid.
§Safety
The caller must guarantee that input.as_ptr().add(index) is valid to
read Self::REQUIRED_MIN_BUFFER_LEN bytes, or that a valid terminating byte
appears before that limit.
Sourcepub unsafe fn write_unchecked(
output: &mut [u8],
index: usize,
value: i128,
) -> usize
pub unsafe fn write_unchecked( output: &mut [u8], index: usize, value: i128, ) -> usize
Encodes value into output starting at index without bounds checks.
§Parameters
output: Destination byte buffer.index: Start index inoutput.value: Value to encode.
§Returns
Returns the number of written bytes.
§Safety
The caller must guarantee that output.as_mut_ptr().add(index) is valid
to write Self::REQUIRED_MIN_BUFFER_LEN bytes.
Source§impl<P> ZigZagCodec<isize, P>where
P: DecodePolicy,
impl<P> ZigZagCodec<isize, P>where
P: DecodePolicy,
Sourcepub const REQUIRED_MIN_BUFFER_LEN: usize = Leb128Codec<usize, NonStrict>::REQUIRED_MIN_BUFFER_LEN
pub const REQUIRED_MIN_BUFFER_LEN: usize = Leb128Codec<usize, NonStrict>::REQUIRED_MIN_BUFFER_LEN
Minimum number of bytes required to encode or decode this type.
Sourcepub unsafe fn read_unchecked(
input: &[u8],
index: usize,
) -> Result<(isize, usize), Leb128DecodeError>
pub unsafe fn read_unchecked( input: &[u8], index: usize, ) -> Result<(isize, usize), 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 number of consumed bytes.
§Errors
Returns Leb128DecodeError if the underlying LEB128 bytes are invalid.
§Safety
The caller must guarantee that input.as_ptr().add(index) is valid to
read Self::REQUIRED_MIN_BUFFER_LEN bytes, or that a valid terminating byte
appears before that limit.
Sourcepub unsafe fn write_unchecked(
output: &mut [u8],
index: usize,
value: isize,
) -> usize
pub unsafe fn write_unchecked( output: &mut [u8], index: usize, value: isize, ) -> usize
Encodes value into output starting at index without bounds checks.
§Parameters
output: Destination byte buffer.index: Start index inoutput.value: Value to encode.
§Returns
Returns the number of written bytes.
§Safety
The caller must guarantee that output.as_mut_ptr().add(index) is valid
to write Self::REQUIRED_MIN_BUFFER_LEN bytes.
Trait Implementations§
Source§impl<T: Clone, P: Clone> Clone for ZigZagCodec<T, P>
impl<T: Clone, P: Clone> Clone for ZigZagCodec<T, P>
Source§fn clone(&self) -> ZigZagCodec<T, P>
fn clone(&self) -> ZigZagCodec<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<T: Default, P: Default> Default for ZigZagCodec<T, P>
impl<T: Default, P: Default> Default for ZigZagCodec<T, P>
Source§fn default() -> ZigZagCodec<T, P>
fn default() -> ZigZagCodec<T, P>
Source§impl<T: PartialEq, P: PartialEq> PartialEq for ZigZagCodec<T, P>
impl<T: PartialEq, P: PartialEq> PartialEq for ZigZagCodec<T, P>
Source§fn eq(&self, other: &ZigZagCodec<T, P>) -> bool
fn eq(&self, other: &ZigZagCodec<T, P>) -> bool
self and other values to be equal, and is used by ==.