Skip to main content

BinaryCodec

Struct BinaryCodec 

Source
pub struct BinaryCodec<T, O> { /* private fields */ }
Expand description

Type-level unchecked binary codec for one scalar type and one byte order.

BinaryCodec is intentionally a zero-sized codec type. It exposes type-level unchecked helpers for direct hot-path use and also implements Codec for generic codec pipelines. Callers must validate buffer lengths before entering the hot path.

§Type Parameters

  • T: Scalar value type to decode from bytes and encode into bytes.
  • O: Type-level byte order marker. Multi-byte scalar implementations use BigEndian or LittleEndian. Single-byte scalar implementations accept any marker because byte order does not affect one-byte values.

§Examples

use qubit_codec_binary::{
    BigEndian,
    BinaryCodec,
};

let mut output = [0_u8; BinaryCodec::<u32, BigEndian>::MAX_UNITS_PER_VALUE];
let written = unsafe {
    BinaryCodec::<u32, BigEndian>::encode_unchecked(0x0102_0304, &mut output, 0)
};
assert_eq!(4, written);
assert_eq!([1, 2, 3, 4], output);

let (decoded, consumed) = unsafe {
    BinaryCodec::<u32, BigEndian>::decode_unchecked(&output, 0)
};
assert_eq!(0x0102_0304, decoded);
assert_eq!(4, consumed.get());

Implementations§

Source§

impl<O> BinaryCodec<u8, O>

Source

pub const MIN_UNITS_PER_VALUE: usize = 1

Minimum number of bytes required to encode or decode this type.

Source

pub const MAX_UNITS_PER_VALUE: usize = Self::MIN_UNITS_PER_VALUE

Maximum number of bytes required to encode or decode this type.

Source

pub unsafe fn decode_unchecked(input: &[u8], index: usize) -> (u8, NonZeroUsize)

Decodes a value from input starting at index without bounds checks.

§Parameters
  • input: Source byte buffer.
  • index: Start index in input.
§Returns

Returns the decoded value and the non-zero number of consumed bytes.

§Safety

The caller must guarantee that input.as_ptr().add(index) is valid to read Self::MIN_UNITS_PER_VALUE bytes.

Source

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 in output.
§Safety

The caller must guarantee that output.as_mut_ptr().add(index) is valid to write Self::MAX_UNITS_PER_VALUE bytes.

Source§

impl<O> BinaryCodec<i8, O>

Source

pub const MIN_UNITS_PER_VALUE: usize = 1

Minimum number of bytes required to encode or decode this type.

Source

pub const MAX_UNITS_PER_VALUE: usize = Self::MIN_UNITS_PER_VALUE

Maximum number of bytes required to encode or decode this type.

Source

pub unsafe fn decode_unchecked(input: &[u8], index: usize) -> (i8, NonZeroUsize)

Decodes a value from input starting at index without bounds checks.

§Parameters
  • input: Source byte buffer.
  • index: Start index in input.
§Returns

Returns the decoded value and the non-zero number of consumed bytes.

§Safety

The caller must guarantee that input.as_ptr().add(index) is valid to read Self::MIN_UNITS_PER_VALUE bytes.

Source

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 in output.
§Safety

The caller must guarantee that output.as_mut_ptr().add(index) is valid to write Self::MAX_UNITS_PER_VALUE bytes.

Source§

impl BinaryCodec<u16, BigEndian>

Source

pub const MIN_UNITS_PER_VALUE: usize = 2

Minimum number of bytes required to encode or decode this type.

Source

pub const MAX_UNITS_PER_VALUE: usize = Self::MIN_UNITS_PER_VALUE

Maximum number of bytes required to encode or decode this type.

Source

pub unsafe fn decode_unchecked( input: &[u8], index: usize, ) -> (u16, NonZeroUsize)

Decodes a value from input starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • input: Source byte buffer.
  • index: Start byte index in input.
§Returns

Returns the decoded value and the non-zero number of consumed bytes.

§Safety

The caller must guarantee that:

  • index + Self::MIN_UNITS_PER_VALUE <= input.len()
  • input[index..index + Self::MIN_UNITS_PER_VALUE] is valid for reading.
Source

pub unsafe fn encode_unchecked( value: u16, output: &mut [u8], index: usize, ) -> usize

Encodes value into output starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • value: Value to encode.
  • output: Destination byte buffer.
  • index: Start byte index in output.
§Safety

The caller must guarantee that:

  • index + Self::MAX_UNITS_PER_VALUE <= output.len()
  • output[index..index + Self::MAX_UNITS_PER_VALUE] is valid for writing.
Source§

impl BinaryCodec<u16, LittleEndian>

Source

pub const MIN_UNITS_PER_VALUE: usize = 2

Minimum number of bytes required to encode or decode this type.

Source

pub const MAX_UNITS_PER_VALUE: usize = Self::MIN_UNITS_PER_VALUE

Maximum number of bytes required to encode or decode this type.

Source

pub unsafe fn decode_unchecked( input: &[u8], index: usize, ) -> (u16, NonZeroUsize)

Decodes a value from input starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • input: Source byte buffer.
  • index: Start byte index in input.
§Returns

Returns the decoded value and the non-zero number of consumed bytes.

§Safety

The caller must guarantee that:

  • index + Self::MIN_UNITS_PER_VALUE <= input.len()
  • input[index..index + Self::MIN_UNITS_PER_VALUE] is valid for reading.
Source

pub unsafe fn encode_unchecked( value: u16, output: &mut [u8], index: usize, ) -> usize

Encodes value into output starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • value: Value to encode.
  • output: Destination byte buffer.
  • index: Start byte index in output.
§Safety

The caller must guarantee that:

  • index + Self::MAX_UNITS_PER_VALUE <= output.len()
  • output[index..index + Self::MAX_UNITS_PER_VALUE] is valid for writing.
Source§

impl BinaryCodec<u32, BigEndian>

Source

pub const MIN_UNITS_PER_VALUE: usize = 4

Minimum number of bytes required to encode or decode this type.

Source

pub const MAX_UNITS_PER_VALUE: usize = Self::MIN_UNITS_PER_VALUE

Maximum number of bytes required to encode or decode this type.

Source

pub unsafe fn decode_unchecked( input: &[u8], index: usize, ) -> (u32, NonZeroUsize)

Decodes a value from input starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • input: Source byte buffer.
  • index: Start byte index in input.
§Returns

Returns the decoded value and the non-zero number of consumed bytes.

§Safety

The caller must guarantee that:

  • index + Self::MIN_UNITS_PER_VALUE <= input.len()
  • input[index..index + Self::MIN_UNITS_PER_VALUE] is valid for reading.
Source

pub unsafe fn encode_unchecked( value: u32, output: &mut [u8], index: usize, ) -> usize

Encodes value into output starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • value: Value to encode.
  • output: Destination byte buffer.
  • index: Start byte index in output.
§Safety

The caller must guarantee that:

  • index + Self::MAX_UNITS_PER_VALUE <= output.len()
  • output[index..index + Self::MAX_UNITS_PER_VALUE] is valid for writing.
Source§

impl BinaryCodec<u32, LittleEndian>

Source

pub const MIN_UNITS_PER_VALUE: usize = 4

Minimum number of bytes required to encode or decode this type.

Source

pub const MAX_UNITS_PER_VALUE: usize = Self::MIN_UNITS_PER_VALUE

Maximum number of bytes required to encode or decode this type.

Source

pub unsafe fn decode_unchecked( input: &[u8], index: usize, ) -> (u32, NonZeroUsize)

Decodes a value from input starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • input: Source byte buffer.
  • index: Start byte index in input.
§Returns

Returns the decoded value and the non-zero number of consumed bytes.

§Safety

The caller must guarantee that:

  • index + Self::MIN_UNITS_PER_VALUE <= input.len()
  • input[index..index + Self::MIN_UNITS_PER_VALUE] is valid for reading.
Source

pub unsafe fn encode_unchecked( value: u32, output: &mut [u8], index: usize, ) -> usize

Encodes value into output starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • value: Value to encode.
  • output: Destination byte buffer.
  • index: Start byte index in output.
§Safety

The caller must guarantee that:

  • index + Self::MAX_UNITS_PER_VALUE <= output.len()
  • output[index..index + Self::MAX_UNITS_PER_VALUE] is valid for writing.
Source§

impl BinaryCodec<u64, BigEndian>

Source

pub const MIN_UNITS_PER_VALUE: usize = 8

Minimum number of bytes required to encode or decode this type.

Source

pub const MAX_UNITS_PER_VALUE: usize = Self::MIN_UNITS_PER_VALUE

Maximum number of bytes required to encode or decode this type.

Source

pub unsafe fn decode_unchecked( input: &[u8], index: usize, ) -> (u64, NonZeroUsize)

Decodes a value from input starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • input: Source byte buffer.
  • index: Start byte index in input.
§Returns

Returns the decoded value and the non-zero number of consumed bytes.

§Safety

The caller must guarantee that:

  • index + Self::MIN_UNITS_PER_VALUE <= input.len()
  • input[index..index + Self::MIN_UNITS_PER_VALUE] is valid for reading.
Source

pub unsafe fn encode_unchecked( value: u64, output: &mut [u8], index: usize, ) -> usize

Encodes value into output starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • value: Value to encode.
  • output: Destination byte buffer.
  • index: Start byte index in output.
§Safety

The caller must guarantee that:

  • index + Self::MAX_UNITS_PER_VALUE <= output.len()
  • output[index..index + Self::MAX_UNITS_PER_VALUE] is valid for writing.
Source§

impl BinaryCodec<u64, LittleEndian>

Source

pub const MIN_UNITS_PER_VALUE: usize = 8

Minimum number of bytes required to encode or decode this type.

Source

pub const MAX_UNITS_PER_VALUE: usize = Self::MIN_UNITS_PER_VALUE

Maximum number of bytes required to encode or decode this type.

Source

pub unsafe fn decode_unchecked( input: &[u8], index: usize, ) -> (u64, NonZeroUsize)

Decodes a value from input starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • input: Source byte buffer.
  • index: Start byte index in input.
§Returns

Returns the decoded value and the non-zero number of consumed bytes.

§Safety

The caller must guarantee that:

  • index + Self::MIN_UNITS_PER_VALUE <= input.len()
  • input[index..index + Self::MIN_UNITS_PER_VALUE] is valid for reading.
Source

pub unsafe fn encode_unchecked( value: u64, output: &mut [u8], index: usize, ) -> usize

Encodes value into output starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • value: Value to encode.
  • output: Destination byte buffer.
  • index: Start byte index in output.
§Safety

The caller must guarantee that:

  • index + Self::MAX_UNITS_PER_VALUE <= output.len()
  • output[index..index + Self::MAX_UNITS_PER_VALUE] is valid for writing.
Source§

impl BinaryCodec<u128, BigEndian>

Source

pub const MIN_UNITS_PER_VALUE: usize = 16

Minimum number of bytes required to encode or decode this type.

Source

pub const MAX_UNITS_PER_VALUE: usize = Self::MIN_UNITS_PER_VALUE

Maximum number of bytes required to encode or decode this type.

Source

pub unsafe fn decode_unchecked( input: &[u8], index: usize, ) -> (u128, NonZeroUsize)

Decodes a value from input starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • input: Source byte buffer.
  • index: Start byte index in input.
§Returns

Returns the decoded value and the non-zero number of consumed bytes.

§Safety

The caller must guarantee that:

  • index + Self::MIN_UNITS_PER_VALUE <= input.len()
  • input[index..index + Self::MIN_UNITS_PER_VALUE] is valid for reading.
Source

pub unsafe fn encode_unchecked( value: u128, output: &mut [u8], index: usize, ) -> usize

Encodes value into output starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • value: Value to encode.
  • output: Destination byte buffer.
  • index: Start byte index in output.
§Safety

The caller must guarantee that:

  • index + Self::MAX_UNITS_PER_VALUE <= output.len()
  • output[index..index + Self::MAX_UNITS_PER_VALUE] is valid for writing.
Source§

impl BinaryCodec<u128, LittleEndian>

Source

pub const MIN_UNITS_PER_VALUE: usize = 16

Minimum number of bytes required to encode or decode this type.

Source

pub const MAX_UNITS_PER_VALUE: usize = Self::MIN_UNITS_PER_VALUE

Maximum number of bytes required to encode or decode this type.

Source

pub unsafe fn decode_unchecked( input: &[u8], index: usize, ) -> (u128, NonZeroUsize)

Decodes a value from input starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • input: Source byte buffer.
  • index: Start byte index in input.
§Returns

Returns the decoded value and the non-zero number of consumed bytes.

§Safety

The caller must guarantee that:

  • index + Self::MIN_UNITS_PER_VALUE <= input.len()
  • input[index..index + Self::MIN_UNITS_PER_VALUE] is valid for reading.
Source

pub unsafe fn encode_unchecked( value: u128, output: &mut [u8], index: usize, ) -> usize

Encodes value into output starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • value: Value to encode.
  • output: Destination byte buffer.
  • index: Start byte index in output.
§Safety

The caller must guarantee that:

  • index + Self::MAX_UNITS_PER_VALUE <= output.len()
  • output[index..index + Self::MAX_UNITS_PER_VALUE] is valid for writing.
Source§

impl BinaryCodec<i16, BigEndian>

Source

pub const MIN_UNITS_PER_VALUE: usize = 2

Minimum number of bytes required to encode or decode this type.

Source

pub const MAX_UNITS_PER_VALUE: usize = Self::MIN_UNITS_PER_VALUE

Maximum number of bytes required to encode or decode this type.

Source

pub unsafe fn decode_unchecked( input: &[u8], index: usize, ) -> (i16, NonZeroUsize)

Decodes a value from input starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • input: Source byte buffer.
  • index: Start byte index in input.
§Returns

Returns the decoded value and the non-zero number of consumed bytes.

§Safety

The caller must guarantee that:

  • index + Self::MIN_UNITS_PER_VALUE <= input.len()
  • input[index..index + Self::MIN_UNITS_PER_VALUE] is valid for reading.
Source

pub unsafe fn encode_unchecked( value: i16, output: &mut [u8], index: usize, ) -> usize

Encodes value into output starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • value: Value to encode.
  • output: Destination byte buffer.
  • index: Start byte index in output.
§Safety

The caller must guarantee that:

  • index + Self::MAX_UNITS_PER_VALUE <= output.len()
  • output[index..index + Self::MAX_UNITS_PER_VALUE] is valid for writing.
Source§

impl BinaryCodec<i16, LittleEndian>

Source

pub const MIN_UNITS_PER_VALUE: usize = 2

Minimum number of bytes required to encode or decode this type.

Source

pub const MAX_UNITS_PER_VALUE: usize = Self::MIN_UNITS_PER_VALUE

Maximum number of bytes required to encode or decode this type.

Source

pub unsafe fn decode_unchecked( input: &[u8], index: usize, ) -> (i16, NonZeroUsize)

Decodes a value from input starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • input: Source byte buffer.
  • index: Start byte index in input.
§Returns

Returns the decoded value and the non-zero number of consumed bytes.

§Safety

The caller must guarantee that:

  • index + Self::MIN_UNITS_PER_VALUE <= input.len()
  • input[index..index + Self::MIN_UNITS_PER_VALUE] is valid for reading.
Source

pub unsafe fn encode_unchecked( value: i16, output: &mut [u8], index: usize, ) -> usize

Encodes value into output starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • value: Value to encode.
  • output: Destination byte buffer.
  • index: Start byte index in output.
§Safety

The caller must guarantee that:

  • index + Self::MAX_UNITS_PER_VALUE <= output.len()
  • output[index..index + Self::MAX_UNITS_PER_VALUE] is valid for writing.
Source§

impl BinaryCodec<i32, BigEndian>

Source

pub const MIN_UNITS_PER_VALUE: usize = 4

Minimum number of bytes required to encode or decode this type.

Source

pub const MAX_UNITS_PER_VALUE: usize = Self::MIN_UNITS_PER_VALUE

Maximum number of bytes required to encode or decode this type.

Source

pub unsafe fn decode_unchecked( input: &[u8], index: usize, ) -> (i32, NonZeroUsize)

Decodes a value from input starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • input: Source byte buffer.
  • index: Start byte index in input.
§Returns

Returns the decoded value and the non-zero number of consumed bytes.

§Safety

The caller must guarantee that:

  • index + Self::MIN_UNITS_PER_VALUE <= input.len()
  • input[index..index + Self::MIN_UNITS_PER_VALUE] is valid for reading.
Source

pub unsafe fn encode_unchecked( value: i32, output: &mut [u8], index: usize, ) -> usize

Encodes value into output starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • value: Value to encode.
  • output: Destination byte buffer.
  • index: Start byte index in output.
§Safety

The caller must guarantee that:

  • index + Self::MAX_UNITS_PER_VALUE <= output.len()
  • output[index..index + Self::MAX_UNITS_PER_VALUE] is valid for writing.
Source§

impl BinaryCodec<i32, LittleEndian>

Source

pub const MIN_UNITS_PER_VALUE: usize = 4

Minimum number of bytes required to encode or decode this type.

Source

pub const MAX_UNITS_PER_VALUE: usize = Self::MIN_UNITS_PER_VALUE

Maximum number of bytes required to encode or decode this type.

Source

pub unsafe fn decode_unchecked( input: &[u8], index: usize, ) -> (i32, NonZeroUsize)

Decodes a value from input starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • input: Source byte buffer.
  • index: Start byte index in input.
§Returns

Returns the decoded value and the non-zero number of consumed bytes.

§Safety

The caller must guarantee that:

  • index + Self::MIN_UNITS_PER_VALUE <= input.len()
  • input[index..index + Self::MIN_UNITS_PER_VALUE] is valid for reading.
Source

pub unsafe fn encode_unchecked( value: i32, output: &mut [u8], index: usize, ) -> usize

Encodes value into output starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • value: Value to encode.
  • output: Destination byte buffer.
  • index: Start byte index in output.
§Safety

The caller must guarantee that:

  • index + Self::MAX_UNITS_PER_VALUE <= output.len()
  • output[index..index + Self::MAX_UNITS_PER_VALUE] is valid for writing.
Source§

impl BinaryCodec<i64, BigEndian>

Source

pub const MIN_UNITS_PER_VALUE: usize = 8

Minimum number of bytes required to encode or decode this type.

Source

pub const MAX_UNITS_PER_VALUE: usize = Self::MIN_UNITS_PER_VALUE

Maximum number of bytes required to encode or decode this type.

Source

pub unsafe fn decode_unchecked( input: &[u8], index: usize, ) -> (i64, NonZeroUsize)

Decodes a value from input starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • input: Source byte buffer.
  • index: Start byte index in input.
§Returns

Returns the decoded value and the non-zero number of consumed bytes.

§Safety

The caller must guarantee that:

  • index + Self::MIN_UNITS_PER_VALUE <= input.len()
  • input[index..index + Self::MIN_UNITS_PER_VALUE] is valid for reading.
Source

pub unsafe fn encode_unchecked( value: i64, output: &mut [u8], index: usize, ) -> usize

Encodes value into output starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • value: Value to encode.
  • output: Destination byte buffer.
  • index: Start byte index in output.
§Safety

The caller must guarantee that:

  • index + Self::MAX_UNITS_PER_VALUE <= output.len()
  • output[index..index + Self::MAX_UNITS_PER_VALUE] is valid for writing.
Source§

impl BinaryCodec<i64, LittleEndian>

Source

pub const MIN_UNITS_PER_VALUE: usize = 8

Minimum number of bytes required to encode or decode this type.

Source

pub const MAX_UNITS_PER_VALUE: usize = Self::MIN_UNITS_PER_VALUE

Maximum number of bytes required to encode or decode this type.

Source

pub unsafe fn decode_unchecked( input: &[u8], index: usize, ) -> (i64, NonZeroUsize)

Decodes a value from input starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • input: Source byte buffer.
  • index: Start byte index in input.
§Returns

Returns the decoded value and the non-zero number of consumed bytes.

§Safety

The caller must guarantee that:

  • index + Self::MIN_UNITS_PER_VALUE <= input.len()
  • input[index..index + Self::MIN_UNITS_PER_VALUE] is valid for reading.
Source

pub unsafe fn encode_unchecked( value: i64, output: &mut [u8], index: usize, ) -> usize

Encodes value into output starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • value: Value to encode.
  • output: Destination byte buffer.
  • index: Start byte index in output.
§Safety

The caller must guarantee that:

  • index + Self::MAX_UNITS_PER_VALUE <= output.len()
  • output[index..index + Self::MAX_UNITS_PER_VALUE] is valid for writing.
Source§

impl BinaryCodec<i128, BigEndian>

Source

pub const MIN_UNITS_PER_VALUE: usize = 16

Minimum number of bytes required to encode or decode this type.

Source

pub const MAX_UNITS_PER_VALUE: usize = Self::MIN_UNITS_PER_VALUE

Maximum number of bytes required to encode or decode this type.

Source

pub unsafe fn decode_unchecked( input: &[u8], index: usize, ) -> (i128, NonZeroUsize)

Decodes a value from input starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • input: Source byte buffer.
  • index: Start byte index in input.
§Returns

Returns the decoded value and the non-zero number of consumed bytes.

§Safety

The caller must guarantee that:

  • index + Self::MIN_UNITS_PER_VALUE <= input.len()
  • input[index..index + Self::MIN_UNITS_PER_VALUE] is valid for reading.
Source

pub unsafe fn encode_unchecked( value: i128, output: &mut [u8], index: usize, ) -> usize

Encodes value into output starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • value: Value to encode.
  • output: Destination byte buffer.
  • index: Start byte index in output.
§Safety

The caller must guarantee that:

  • index + Self::MAX_UNITS_PER_VALUE <= output.len()
  • output[index..index + Self::MAX_UNITS_PER_VALUE] is valid for writing.
Source§

impl BinaryCodec<i128, LittleEndian>

Source

pub const MIN_UNITS_PER_VALUE: usize = 16

Minimum number of bytes required to encode or decode this type.

Source

pub const MAX_UNITS_PER_VALUE: usize = Self::MIN_UNITS_PER_VALUE

Maximum number of bytes required to encode or decode this type.

Source

pub unsafe fn decode_unchecked( input: &[u8], index: usize, ) -> (i128, NonZeroUsize)

Decodes a value from input starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • input: Source byte buffer.
  • index: Start byte index in input.
§Returns

Returns the decoded value and the non-zero number of consumed bytes.

§Safety

The caller must guarantee that:

  • index + Self::MIN_UNITS_PER_VALUE <= input.len()
  • input[index..index + Self::MIN_UNITS_PER_VALUE] is valid for reading.
Source

pub unsafe fn encode_unchecked( value: i128, output: &mut [u8], index: usize, ) -> usize

Encodes value into output starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • value: Value to encode.
  • output: Destination byte buffer.
  • index: Start byte index in output.
§Safety

The caller must guarantee that:

  • index + Self::MAX_UNITS_PER_VALUE <= output.len()
  • output[index..index + Self::MAX_UNITS_PER_VALUE] is valid for writing.
Source§

impl BinaryCodec<f32, BigEndian>

Source

pub const MIN_UNITS_PER_VALUE: usize = 4

Minimum number of bytes required to encode or decode this type.

Source

pub const MAX_UNITS_PER_VALUE: usize = Self::MIN_UNITS_PER_VALUE

Maximum number of bytes required to encode or decode this type.

Source

pub unsafe fn decode_unchecked( input: &[u8], index: usize, ) -> (f32, NonZeroUsize)

Decodes a value from input starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • input: Source byte buffer.
  • index: Start byte index in input.
§Returns

Returns the decoded floating-point value and the non-zero number of consumed bytes.

§Safety

The caller must guarantee that:

  • index + Self::MIN_UNITS_PER_VALUE <= input.len()
  • input[index..index + Self::MIN_UNITS_PER_VALUE] is valid for reading.
Source

pub unsafe fn encode_unchecked( value: f32, output: &mut [u8], index: usize, ) -> usize

Encodes value into output starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • value: Floating-point value to encode.
  • output: Destination byte buffer.
  • index: Start byte index in output.
§Safety

The caller must guarantee that:

  • index + Self::MAX_UNITS_PER_VALUE <= output.len()
  • output[index..index + Self::MAX_UNITS_PER_VALUE] is valid for writing.
Source§

impl BinaryCodec<f32, LittleEndian>

Source

pub const MIN_UNITS_PER_VALUE: usize = 4

Minimum number of bytes required to encode or decode this type.

Source

pub const MAX_UNITS_PER_VALUE: usize = Self::MIN_UNITS_PER_VALUE

Maximum number of bytes required to encode or decode this type.

Source

pub unsafe fn decode_unchecked( input: &[u8], index: usize, ) -> (f32, NonZeroUsize)

Decodes a value from input starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • input: Source byte buffer.
  • index: Start byte index in input.
§Returns

Returns the decoded floating-point value and the non-zero number of consumed bytes.

§Safety

The caller must guarantee that:

  • index + Self::MIN_UNITS_PER_VALUE <= input.len()
  • input[index..index + Self::MIN_UNITS_PER_VALUE] is valid for reading.
Source

pub unsafe fn encode_unchecked( value: f32, output: &mut [u8], index: usize, ) -> usize

Encodes value into output starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • value: Floating-point value to encode.
  • output: Destination byte buffer.
  • index: Start byte index in output.
§Safety

The caller must guarantee that:

  • index + Self::MAX_UNITS_PER_VALUE <= output.len()
  • output[index..index + Self::MAX_UNITS_PER_VALUE] is valid for writing.
Source§

impl BinaryCodec<f64, BigEndian>

Source

pub const MIN_UNITS_PER_VALUE: usize = 8

Minimum number of bytes required to encode or decode this type.

Source

pub const MAX_UNITS_PER_VALUE: usize = Self::MIN_UNITS_PER_VALUE

Maximum number of bytes required to encode or decode this type.

Source

pub unsafe fn decode_unchecked( input: &[u8], index: usize, ) -> (f64, NonZeroUsize)

Decodes a value from input starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • input: Source byte buffer.
  • index: Start byte index in input.
§Returns

Returns the decoded floating-point value and the non-zero number of consumed bytes.

§Safety

The caller must guarantee that:

  • index + Self::MIN_UNITS_PER_VALUE <= input.len()
  • input[index..index + Self::MIN_UNITS_PER_VALUE] is valid for reading.
Source

pub unsafe fn encode_unchecked( value: f64, output: &mut [u8], index: usize, ) -> usize

Encodes value into output starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • value: Floating-point value to encode.
  • output: Destination byte buffer.
  • index: Start byte index in output.
§Safety

The caller must guarantee that:

  • index + Self::MAX_UNITS_PER_VALUE <= output.len()
  • output[index..index + Self::MAX_UNITS_PER_VALUE] is valid for writing.
Source§

impl BinaryCodec<f64, LittleEndian>

Source

pub const MIN_UNITS_PER_VALUE: usize = 8

Minimum number of bytes required to encode or decode this type.

Source

pub const MAX_UNITS_PER_VALUE: usize = Self::MIN_UNITS_PER_VALUE

Maximum number of bytes required to encode or decode this type.

Source

pub unsafe fn decode_unchecked( input: &[u8], index: usize, ) -> (f64, NonZeroUsize)

Decodes a value from input starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • input: Source byte buffer.
  • index: Start byte index in input.
§Returns

Returns the decoded floating-point value and the non-zero number of consumed bytes.

§Safety

The caller must guarantee that:

  • index + Self::MIN_UNITS_PER_VALUE <= input.len()
  • input[index..index + Self::MIN_UNITS_PER_VALUE] is valid for reading.
Source

pub unsafe fn encode_unchecked( value: f64, output: &mut [u8], index: usize, ) -> usize

Encodes value into output starting at index without bounds checks.

This function is intended for hot binary codec paths where the caller has already validated the buffer length externally.

§Parameters
  • value: Floating-point value to encode.
  • output: Destination byte buffer.
  • index: Start byte index in output.
§Safety

The caller must guarantee that:

  • index + Self::MAX_UNITS_PER_VALUE <= output.len()
  • output[index..index + Self::MAX_UNITS_PER_VALUE] is valid for writing.

Trait Implementations§

Source§

impl<T: Clone, O: Clone> Clone for BinaryCodec<T, O>

Source§

fn clone(&self) -> BinaryCodec<T, O>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Codec for BinaryCodec<f32, BigEndian>

Source§

type Value = f32

Logical value decoded from or encoded into the buffer.
Source§

type Unit = u8

Buffer unit used by the encoded representation.
Source§

type DecodeError = Infallible

Error reported when decoding malformed units.
Source§

type EncodeError = Infallible

Error reported when encoding an unsupported value.
Source§

fn min_units_per_value(&self) -> NonZeroUsize

Returns the minimum possible unit count for one encoded value. Read more
Source§

fn max_units_per_value(&self) -> NonZeroUsize

Returns the maximum non-zero unit count needed to encode or decode one value. Read more
Source§

unsafe fn decode_unchecked( &self, input: &[u8], index: usize, ) -> Result<(f32, NonZeroUsize), Self::DecodeError>

Decodes one value from input starting at index. Read more
Source§

unsafe fn encode_unchecked( &self, value: &f32, output: &mut [u8], index: usize, ) -> Result<usize, Self::EncodeError>

Encodes one borrowed value into output starting at index. Read more
Source§

impl Codec for BinaryCodec<f32, LittleEndian>

Source§

type Value = f32

Logical value decoded from or encoded into the buffer.
Source§

type Unit = u8

Buffer unit used by the encoded representation.
Source§

type DecodeError = Infallible

Error reported when decoding malformed units.
Source§

type EncodeError = Infallible

Error reported when encoding an unsupported value.
Source§

fn min_units_per_value(&self) -> NonZeroUsize

Returns the minimum possible unit count for one encoded value. Read more
Source§

fn max_units_per_value(&self) -> NonZeroUsize

Returns the maximum non-zero unit count needed to encode or decode one value. Read more
Source§

unsafe fn decode_unchecked( &self, input: &[u8], index: usize, ) -> Result<(f32, NonZeroUsize), Self::DecodeError>

Decodes one value from input starting at index. Read more
Source§

unsafe fn encode_unchecked( &self, value: &f32, output: &mut [u8], index: usize, ) -> Result<usize, Self::EncodeError>

Encodes one borrowed value into output starting at index. Read more
Source§

impl Codec for BinaryCodec<f64, BigEndian>

Source§

type Value = f64

Logical value decoded from or encoded into the buffer.
Source§

type Unit = u8

Buffer unit used by the encoded representation.
Source§

type DecodeError = Infallible

Error reported when decoding malformed units.
Source§

type EncodeError = Infallible

Error reported when encoding an unsupported value.
Source§

fn min_units_per_value(&self) -> NonZeroUsize

Returns the minimum possible unit count for one encoded value. Read more
Source§

fn max_units_per_value(&self) -> NonZeroUsize

Returns the maximum non-zero unit count needed to encode or decode one value. Read more
Source§

unsafe fn decode_unchecked( &self, input: &[u8], index: usize, ) -> Result<(f64, NonZeroUsize), Self::DecodeError>

Decodes one value from input starting at index. Read more
Source§

unsafe fn encode_unchecked( &self, value: &f64, output: &mut [u8], index: usize, ) -> Result<usize, Self::EncodeError>

Encodes one borrowed value into output starting at index. Read more
Source§

impl Codec for BinaryCodec<f64, LittleEndian>

Source§

type Value = f64

Logical value decoded from or encoded into the buffer.
Source§

type Unit = u8

Buffer unit used by the encoded representation.
Source§

type DecodeError = Infallible

Error reported when decoding malformed units.
Source§

type EncodeError = Infallible

Error reported when encoding an unsupported value.
Source§

fn min_units_per_value(&self) -> NonZeroUsize

Returns the minimum possible unit count for one encoded value. Read more
Source§

fn max_units_per_value(&self) -> NonZeroUsize

Returns the maximum non-zero unit count needed to encode or decode one value. Read more
Source§

unsafe fn decode_unchecked( &self, input: &[u8], index: usize, ) -> Result<(f64, NonZeroUsize), Self::DecodeError>

Decodes one value from input starting at index. Read more
Source§

unsafe fn encode_unchecked( &self, value: &f64, output: &mut [u8], index: usize, ) -> Result<usize, Self::EncodeError>

Encodes one borrowed value into output starting at index. Read more
Source§

impl Codec for BinaryCodec<i128, BigEndian>

Source§

type Value = i128

Logical value decoded from or encoded into the buffer.
Source§

type Unit = u8

Buffer unit used by the encoded representation.
Source§

type DecodeError = Infallible

Error reported when decoding malformed units.
Source§

type EncodeError = Infallible

Error reported when encoding an unsupported value.
Source§

fn min_units_per_value(&self) -> NonZeroUsize

Returns the minimum possible unit count for one encoded value. Read more
Source§

fn max_units_per_value(&self) -> NonZeroUsize

Returns the maximum non-zero unit count needed to encode or decode one value. Read more
Source§

unsafe fn decode_unchecked( &self, input: &[u8], index: usize, ) -> Result<(i128, NonZeroUsize), Self::DecodeError>

Decodes one value from input starting at index. Read more
Source§

unsafe fn encode_unchecked( &self, value: &i128, output: &mut [u8], index: usize, ) -> Result<usize, Self::EncodeError>

Encodes one borrowed value into output starting at index. Read more
Source§

impl Codec for BinaryCodec<i128, LittleEndian>

Source§

type Value = i128

Logical value decoded from or encoded into the buffer.
Source§

type Unit = u8

Buffer unit used by the encoded representation.
Source§

type DecodeError = Infallible

Error reported when decoding malformed units.
Source§

type EncodeError = Infallible

Error reported when encoding an unsupported value.
Source§

fn min_units_per_value(&self) -> NonZeroUsize

Returns the minimum possible unit count for one encoded value. Read more
Source§

fn max_units_per_value(&self) -> NonZeroUsize

Returns the maximum non-zero unit count needed to encode or decode one value. Read more
Source§

unsafe fn decode_unchecked( &self, input: &[u8], index: usize, ) -> Result<(i128, NonZeroUsize), Self::DecodeError>

Decodes one value from input starting at index. Read more
Source§

unsafe fn encode_unchecked( &self, value: &i128, output: &mut [u8], index: usize, ) -> Result<usize, Self::EncodeError>

Encodes one borrowed value into output starting at index. Read more
Source§

impl Codec for BinaryCodec<i16, BigEndian>

Source§

type Value = i16

Logical value decoded from or encoded into the buffer.
Source§

type Unit = u8

Buffer unit used by the encoded representation.
Source§

type DecodeError = Infallible

Error reported when decoding malformed units.
Source§

type EncodeError = Infallible

Error reported when encoding an unsupported value.
Source§

fn min_units_per_value(&self) -> NonZeroUsize

Returns the minimum possible unit count for one encoded value. Read more
Source§

fn max_units_per_value(&self) -> NonZeroUsize

Returns the maximum non-zero unit count needed to encode or decode one value. Read more
Source§

unsafe fn decode_unchecked( &self, input: &[u8], index: usize, ) -> Result<(i16, NonZeroUsize), Self::DecodeError>

Decodes one value from input starting at index. Read more
Source§

unsafe fn encode_unchecked( &self, value: &i16, output: &mut [u8], index: usize, ) -> Result<usize, Self::EncodeError>

Encodes one borrowed value into output starting at index. Read more
Source§

impl Codec for BinaryCodec<i16, LittleEndian>

Source§

type Value = i16

Logical value decoded from or encoded into the buffer.
Source§

type Unit = u8

Buffer unit used by the encoded representation.
Source§

type DecodeError = Infallible

Error reported when decoding malformed units.
Source§

type EncodeError = Infallible

Error reported when encoding an unsupported value.
Source§

fn min_units_per_value(&self) -> NonZeroUsize

Returns the minimum possible unit count for one encoded value. Read more
Source§

fn max_units_per_value(&self) -> NonZeroUsize

Returns the maximum non-zero unit count needed to encode or decode one value. Read more
Source§

unsafe fn decode_unchecked( &self, input: &[u8], index: usize, ) -> Result<(i16, NonZeroUsize), Self::DecodeError>

Decodes one value from input starting at index. Read more
Source§

unsafe fn encode_unchecked( &self, value: &i16, output: &mut [u8], index: usize, ) -> Result<usize, Self::EncodeError>

Encodes one borrowed value into output starting at index. Read more
Source§

impl Codec for BinaryCodec<i32, BigEndian>

Source§

type Value = i32

Logical value decoded from or encoded into the buffer.
Source§

type Unit = u8

Buffer unit used by the encoded representation.
Source§

type DecodeError = Infallible

Error reported when decoding malformed units.
Source§

type EncodeError = Infallible

Error reported when encoding an unsupported value.
Source§

fn min_units_per_value(&self) -> NonZeroUsize

Returns the minimum possible unit count for one encoded value. Read more
Source§

fn max_units_per_value(&self) -> NonZeroUsize

Returns the maximum non-zero unit count needed to encode or decode one value. Read more
Source§

unsafe fn decode_unchecked( &self, input: &[u8], index: usize, ) -> Result<(i32, NonZeroUsize), Self::DecodeError>

Decodes one value from input starting at index. Read more
Source§

unsafe fn encode_unchecked( &self, value: &i32, output: &mut [u8], index: usize, ) -> Result<usize, Self::EncodeError>

Encodes one borrowed value into output starting at index. Read more
Source§

impl Codec for BinaryCodec<i32, LittleEndian>

Source§

type Value = i32

Logical value decoded from or encoded into the buffer.
Source§

type Unit = u8

Buffer unit used by the encoded representation.
Source§

type DecodeError = Infallible

Error reported when decoding malformed units.
Source§

type EncodeError = Infallible

Error reported when encoding an unsupported value.
Source§

fn min_units_per_value(&self) -> NonZeroUsize

Returns the minimum possible unit count for one encoded value. Read more
Source§

fn max_units_per_value(&self) -> NonZeroUsize

Returns the maximum non-zero unit count needed to encode or decode one value. Read more
Source§

unsafe fn decode_unchecked( &self, input: &[u8], index: usize, ) -> Result<(i32, NonZeroUsize), Self::DecodeError>

Decodes one value from input starting at index. Read more
Source§

unsafe fn encode_unchecked( &self, value: &i32, output: &mut [u8], index: usize, ) -> Result<usize, Self::EncodeError>

Encodes one borrowed value into output starting at index. Read more
Source§

impl Codec for BinaryCodec<i64, BigEndian>

Source§

type Value = i64

Logical value decoded from or encoded into the buffer.
Source§

type Unit = u8

Buffer unit used by the encoded representation.
Source§

type DecodeError = Infallible

Error reported when decoding malformed units.
Source§

type EncodeError = Infallible

Error reported when encoding an unsupported value.
Source§

fn min_units_per_value(&self) -> NonZeroUsize

Returns the minimum possible unit count for one encoded value. Read more
Source§

fn max_units_per_value(&self) -> NonZeroUsize

Returns the maximum non-zero unit count needed to encode or decode one value. Read more
Source§

unsafe fn decode_unchecked( &self, input: &[u8], index: usize, ) -> Result<(i64, NonZeroUsize), Self::DecodeError>

Decodes one value from input starting at index. Read more
Source§

unsafe fn encode_unchecked( &self, value: &i64, output: &mut [u8], index: usize, ) -> Result<usize, Self::EncodeError>

Encodes one borrowed value into output starting at index. Read more
Source§

impl Codec for BinaryCodec<i64, LittleEndian>

Source§

type Value = i64

Logical value decoded from or encoded into the buffer.
Source§

type Unit = u8

Buffer unit used by the encoded representation.
Source§

type DecodeError = Infallible

Error reported when decoding malformed units.
Source§

type EncodeError = Infallible

Error reported when encoding an unsupported value.
Source§

fn min_units_per_value(&self) -> NonZeroUsize

Returns the minimum possible unit count for one encoded value. Read more
Source§

fn max_units_per_value(&self) -> NonZeroUsize

Returns the maximum non-zero unit count needed to encode or decode one value. Read more
Source§

unsafe fn decode_unchecked( &self, input: &[u8], index: usize, ) -> Result<(i64, NonZeroUsize), Self::DecodeError>

Decodes one value from input starting at index. Read more
Source§

unsafe fn encode_unchecked( &self, value: &i64, output: &mut [u8], index: usize, ) -> Result<usize, Self::EncodeError>

Encodes one borrowed value into output starting at index. Read more
Source§

impl<O> Codec for BinaryCodec<i8, O>

Source§

type Value = i8

Logical value decoded from or encoded into the buffer.
Source§

type Unit = u8

Buffer unit used by the encoded representation.
Source§

type DecodeError = Infallible

Error reported when decoding malformed units.
Source§

type EncodeError = Infallible

Error reported when encoding an unsupported value.
Source§

fn min_units_per_value(&self) -> NonZeroUsize

Returns the minimum possible unit count for one encoded value. Read more
Source§

fn max_units_per_value(&self) -> NonZeroUsize

Returns the maximum non-zero unit count needed to encode or decode one value. Read more
Source§

unsafe fn decode_unchecked( &self, input: &[u8], index: usize, ) -> Result<(i8, NonZeroUsize), Self::DecodeError>

Decodes one value from input starting at index. Read more
Source§

unsafe fn encode_unchecked( &self, value: &i8, output: &mut [u8], index: usize, ) -> Result<usize, Self::EncodeError>

Encodes one borrowed value into output starting at index. Read more
Source§

impl Codec for BinaryCodec<u128, BigEndian>

Source§

type Value = u128

Logical value decoded from or encoded into the buffer.
Source§

type Unit = u8

Buffer unit used by the encoded representation.
Source§

type DecodeError = Infallible

Error reported when decoding malformed units.
Source§

type EncodeError = Infallible

Error reported when encoding an unsupported value.
Source§

fn min_units_per_value(&self) -> NonZeroUsize

Returns the minimum possible unit count for one encoded value. Read more
Source§

fn max_units_per_value(&self) -> NonZeroUsize

Returns the maximum non-zero unit count needed to encode or decode one value. Read more
Source§

unsafe fn decode_unchecked( &self, input: &[u8], index: usize, ) -> Result<(u128, NonZeroUsize), Self::DecodeError>

Decodes one value from input starting at index. Read more
Source§

unsafe fn encode_unchecked( &self, value: &u128, output: &mut [u8], index: usize, ) -> Result<usize, Self::EncodeError>

Encodes one borrowed value into output starting at index. Read more
Source§

impl Codec for BinaryCodec<u128, LittleEndian>

Source§

type Value = u128

Logical value decoded from or encoded into the buffer.
Source§

type Unit = u8

Buffer unit used by the encoded representation.
Source§

type DecodeError = Infallible

Error reported when decoding malformed units.
Source§

type EncodeError = Infallible

Error reported when encoding an unsupported value.
Source§

fn min_units_per_value(&self) -> NonZeroUsize

Returns the minimum possible unit count for one encoded value. Read more
Source§

fn max_units_per_value(&self) -> NonZeroUsize

Returns the maximum non-zero unit count needed to encode or decode one value. Read more
Source§

unsafe fn decode_unchecked( &self, input: &[u8], index: usize, ) -> Result<(u128, NonZeroUsize), Self::DecodeError>

Decodes one value from input starting at index. Read more
Source§

unsafe fn encode_unchecked( &self, value: &u128, output: &mut [u8], index: usize, ) -> Result<usize, Self::EncodeError>

Encodes one borrowed value into output starting at index. Read more
Source§

impl Codec for BinaryCodec<u16, BigEndian>

Source§

type Value = u16

Logical value decoded from or encoded into the buffer.
Source§

type Unit = u8

Buffer unit used by the encoded representation.
Source§

type DecodeError = Infallible

Error reported when decoding malformed units.
Source§

type EncodeError = Infallible

Error reported when encoding an unsupported value.
Source§

fn min_units_per_value(&self) -> NonZeroUsize

Returns the minimum possible unit count for one encoded value. Read more
Source§

fn max_units_per_value(&self) -> NonZeroUsize

Returns the maximum non-zero unit count needed to encode or decode one value. Read more
Source§

unsafe fn decode_unchecked( &self, input: &[u8], index: usize, ) -> Result<(u16, NonZeroUsize), Self::DecodeError>

Decodes one value from input starting at index. Read more
Source§

unsafe fn encode_unchecked( &self, value: &u16, output: &mut [u8], index: usize, ) -> Result<usize, Self::EncodeError>

Encodes one borrowed value into output starting at index. Read more
Source§

impl Codec for BinaryCodec<u16, LittleEndian>

Source§

type Value = u16

Logical value decoded from or encoded into the buffer.
Source§

type Unit = u8

Buffer unit used by the encoded representation.
Source§

type DecodeError = Infallible

Error reported when decoding malformed units.
Source§

type EncodeError = Infallible

Error reported when encoding an unsupported value.
Source§

fn min_units_per_value(&self) -> NonZeroUsize

Returns the minimum possible unit count for one encoded value. Read more
Source§

fn max_units_per_value(&self) -> NonZeroUsize

Returns the maximum non-zero unit count needed to encode or decode one value. Read more
Source§

unsafe fn decode_unchecked( &self, input: &[u8], index: usize, ) -> Result<(u16, NonZeroUsize), Self::DecodeError>

Decodes one value from input starting at index. Read more
Source§

unsafe fn encode_unchecked( &self, value: &u16, output: &mut [u8], index: usize, ) -> Result<usize, Self::EncodeError>

Encodes one borrowed value into output starting at index. Read more
Source§

impl Codec for BinaryCodec<u32, BigEndian>

Source§

type Value = u32

Logical value decoded from or encoded into the buffer.
Source§

type Unit = u8

Buffer unit used by the encoded representation.
Source§

type DecodeError = Infallible

Error reported when decoding malformed units.
Source§

type EncodeError = Infallible

Error reported when encoding an unsupported value.
Source§

fn min_units_per_value(&self) -> NonZeroUsize

Returns the minimum possible unit count for one encoded value. Read more
Source§

fn max_units_per_value(&self) -> NonZeroUsize

Returns the maximum non-zero unit count needed to encode or decode one value. Read more
Source§

unsafe fn decode_unchecked( &self, input: &[u8], index: usize, ) -> Result<(u32, NonZeroUsize), Self::DecodeError>

Decodes one value from input starting at index. Read more
Source§

unsafe fn encode_unchecked( &self, value: &u32, output: &mut [u8], index: usize, ) -> Result<usize, Self::EncodeError>

Encodes one borrowed value into output starting at index. Read more
Source§

impl Codec for BinaryCodec<u32, LittleEndian>

Source§

type Value = u32

Logical value decoded from or encoded into the buffer.
Source§

type Unit = u8

Buffer unit used by the encoded representation.
Source§

type DecodeError = Infallible

Error reported when decoding malformed units.
Source§

type EncodeError = Infallible

Error reported when encoding an unsupported value.
Source§

fn min_units_per_value(&self) -> NonZeroUsize

Returns the minimum possible unit count for one encoded value. Read more
Source§

fn max_units_per_value(&self) -> NonZeroUsize

Returns the maximum non-zero unit count needed to encode or decode one value. Read more
Source§

unsafe fn decode_unchecked( &self, input: &[u8], index: usize, ) -> Result<(u32, NonZeroUsize), Self::DecodeError>

Decodes one value from input starting at index. Read more
Source§

unsafe fn encode_unchecked( &self, value: &u32, output: &mut [u8], index: usize, ) -> Result<usize, Self::EncodeError>

Encodes one borrowed value into output starting at index. Read more
Source§

impl Codec for BinaryCodec<u64, BigEndian>

Source§

type Value = u64

Logical value decoded from or encoded into the buffer.
Source§

type Unit = u8

Buffer unit used by the encoded representation.
Source§

type DecodeError = Infallible

Error reported when decoding malformed units.
Source§

type EncodeError = Infallible

Error reported when encoding an unsupported value.
Source§

fn min_units_per_value(&self) -> NonZeroUsize

Returns the minimum possible unit count for one encoded value. Read more
Source§

fn max_units_per_value(&self) -> NonZeroUsize

Returns the maximum non-zero unit count needed to encode or decode one value. Read more
Source§

unsafe fn decode_unchecked( &self, input: &[u8], index: usize, ) -> Result<(u64, NonZeroUsize), Self::DecodeError>

Decodes one value from input starting at index. Read more
Source§

unsafe fn encode_unchecked( &self, value: &u64, output: &mut [u8], index: usize, ) -> Result<usize, Self::EncodeError>

Encodes one borrowed value into output starting at index. Read more
Source§

impl Codec for BinaryCodec<u64, LittleEndian>

Source§

type Value = u64

Logical value decoded from or encoded into the buffer.
Source§

type Unit = u8

Buffer unit used by the encoded representation.
Source§

type DecodeError = Infallible

Error reported when decoding malformed units.
Source§

type EncodeError = Infallible

Error reported when encoding an unsupported value.
Source§

fn min_units_per_value(&self) -> NonZeroUsize

Returns the minimum possible unit count for one encoded value. Read more
Source§

fn max_units_per_value(&self) -> NonZeroUsize

Returns the maximum non-zero unit count needed to encode or decode one value. Read more
Source§

unsafe fn decode_unchecked( &self, input: &[u8], index: usize, ) -> Result<(u64, NonZeroUsize), Self::DecodeError>

Decodes one value from input starting at index. Read more
Source§

unsafe fn encode_unchecked( &self, value: &u64, output: &mut [u8], index: usize, ) -> Result<usize, Self::EncodeError>

Encodes one borrowed value into output starting at index. Read more
Source§

impl<O> Codec for BinaryCodec<u8, O>

Source§

type Value = u8

Logical value decoded from or encoded into the buffer.
Source§

type Unit = u8

Buffer unit used by the encoded representation.
Source§

type DecodeError = Infallible

Error reported when decoding malformed units.
Source§

type EncodeError = Infallible

Error reported when encoding an unsupported value.
Source§

fn min_units_per_value(&self) -> NonZeroUsize

Returns the minimum possible unit count for one encoded value. Read more
Source§

fn max_units_per_value(&self) -> NonZeroUsize

Returns the maximum non-zero unit count needed to encode or decode one value. Read more
Source§

unsafe fn decode_unchecked( &self, input: &[u8], index: usize, ) -> Result<(u8, NonZeroUsize), Self::DecodeError>

Decodes one value from input starting at index. Read more
Source§

unsafe fn encode_unchecked( &self, value: &u8, output: &mut [u8], index: usize, ) -> Result<usize, Self::EncodeError>

Encodes one borrowed value into output starting at index. Read more
Source§

impl<T: Copy, O: Copy> Copy for BinaryCodec<T, O>

Source§

impl<T: Debug, O: Debug> Debug for BinaryCodec<T, O>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Default, O: Default> Default for BinaryCodec<T, O>

Source§

fn default() -> BinaryCodec<T, O>

Returns the “default value” for a type. Read more
Source§

impl<T: Eq, O: Eq> Eq for BinaryCodec<T, O>

Source§

impl<T: Hash, O: Hash> Hash for BinaryCodec<T, O>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T: PartialEq, O: PartialEq> PartialEq for BinaryCodec<T, O>

Source§

fn eq(&self, other: &BinaryCodec<T, O>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T, O> StructuralPartialEq for BinaryCodec<T, O>

Auto Trait Implementations§

§

impl<T, O> Freeze for BinaryCodec<T, O>

§

impl<T, O> RefUnwindSafe for BinaryCodec<T, O>

§

impl<T, O> Send for BinaryCodec<T, O>

§

impl<T, O> Sync for BinaryCodec<T, O>

§

impl<T, O> Unpin for BinaryCodec<T, O>

§

impl<T, O> UnsafeUnpin for BinaryCodec<T, O>

§

impl<T, O> UnwindSafe for BinaryCodec<T, O>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.