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 static namespace. It does not provide safe checked helpers, constructors, or instance methods. Callers must validate buffer lengths before entering the hot path.

Implementations§

Source§

impl<O> BinaryCodec<u8, O>

Source

pub const REQUIRED_MIN_BUFFER_LEN: usize = 1

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

Source

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

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.

§Safety

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

Source

pub unsafe fn write_unchecked(output: &mut [u8], index: usize, value: u8)

Encodes value into output starting at index without bounds checks.

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

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

Source§

impl<O> BinaryCodec<i8, O>

Source

pub const REQUIRED_MIN_BUFFER_LEN: usize = 1

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

Source

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

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.

§Safety

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

Source

pub unsafe fn write_unchecked(output: &mut [u8], index: usize, value: i8)

Encodes value into output starting at index without bounds checks.

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

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

Source§

impl BinaryCodec<u16, BigEndian>

Source

pub const REQUIRED_MIN_BUFFER_LEN: usize = 2

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

Source

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

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.

§Safety

The caller must guarantee that:

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

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

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
  • output: Destination byte buffer.
  • index: Start byte index in output.
  • value: Value to encode.
§Safety

The caller must guarantee that:

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

impl BinaryCodec<u16, LittleEndian>

Source

pub const REQUIRED_MIN_BUFFER_LEN: usize = 2

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

Source

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

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.

§Safety

The caller must guarantee that:

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

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

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
  • output: Destination byte buffer.
  • index: Start byte index in output.
  • value: Value to encode.
§Safety

The caller must guarantee that:

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

impl BinaryCodec<u32, BigEndian>

Source

pub const REQUIRED_MIN_BUFFER_LEN: usize = 4

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

Source

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

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.

§Safety

The caller must guarantee that:

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

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

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
  • output: Destination byte buffer.
  • index: Start byte index in output.
  • value: Value to encode.
§Safety

The caller must guarantee that:

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

impl BinaryCodec<u32, LittleEndian>

Source

pub const REQUIRED_MIN_BUFFER_LEN: usize = 4

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

Source

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

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.

§Safety

The caller must guarantee that:

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

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

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
  • output: Destination byte buffer.
  • index: Start byte index in output.
  • value: Value to encode.
§Safety

The caller must guarantee that:

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

impl BinaryCodec<u64, BigEndian>

Source

pub const REQUIRED_MIN_BUFFER_LEN: usize = 8

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

Source

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

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.

§Safety

The caller must guarantee that:

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

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

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
  • output: Destination byte buffer.
  • index: Start byte index in output.
  • value: Value to encode.
§Safety

The caller must guarantee that:

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

impl BinaryCodec<u64, LittleEndian>

Source

pub const REQUIRED_MIN_BUFFER_LEN: usize = 8

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

Source

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

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.

§Safety

The caller must guarantee that:

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

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

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
  • output: Destination byte buffer.
  • index: Start byte index in output.
  • value: Value to encode.
§Safety

The caller must guarantee that:

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

impl BinaryCodec<u128, BigEndian>

Source

pub const REQUIRED_MIN_BUFFER_LEN: usize = 16

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

Source

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

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.

§Safety

The caller must guarantee that:

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

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

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
  • output: Destination byte buffer.
  • index: Start byte index in output.
  • value: Value to encode.
§Safety

The caller must guarantee that:

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

impl BinaryCodec<u128, LittleEndian>

Source

pub const REQUIRED_MIN_BUFFER_LEN: usize = 16

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

Source

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

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.

§Safety

The caller must guarantee that:

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

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

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
  • output: Destination byte buffer.
  • index: Start byte index in output.
  • value: Value to encode.
§Safety

The caller must guarantee that:

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

impl BinaryCodec<i16, BigEndian>

Source

pub const REQUIRED_MIN_BUFFER_LEN: usize = 2

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

Source

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

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.

§Safety

The caller must guarantee that:

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

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

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
  • output: Destination byte buffer.
  • index: Start byte index in output.
  • value: Value to encode.
§Safety

The caller must guarantee that:

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

impl BinaryCodec<i16, LittleEndian>

Source

pub const REQUIRED_MIN_BUFFER_LEN: usize = 2

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

Source

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

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.

§Safety

The caller must guarantee that:

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

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

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
  • output: Destination byte buffer.
  • index: Start byte index in output.
  • value: Value to encode.
§Safety

The caller must guarantee that:

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

impl BinaryCodec<i32, BigEndian>

Source

pub const REQUIRED_MIN_BUFFER_LEN: usize = 4

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

Source

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

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.

§Safety

The caller must guarantee that:

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

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

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
  • output: Destination byte buffer.
  • index: Start byte index in output.
  • value: Value to encode.
§Safety

The caller must guarantee that:

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

impl BinaryCodec<i32, LittleEndian>

Source

pub const REQUIRED_MIN_BUFFER_LEN: usize = 4

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

Source

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

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.

§Safety

The caller must guarantee that:

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

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

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
  • output: Destination byte buffer.
  • index: Start byte index in output.
  • value: Value to encode.
§Safety

The caller must guarantee that:

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

impl BinaryCodec<i64, BigEndian>

Source

pub const REQUIRED_MIN_BUFFER_LEN: usize = 8

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

Source

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

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.

§Safety

The caller must guarantee that:

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

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

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
  • output: Destination byte buffer.
  • index: Start byte index in output.
  • value: Value to encode.
§Safety

The caller must guarantee that:

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

impl BinaryCodec<i64, LittleEndian>

Source

pub const REQUIRED_MIN_BUFFER_LEN: usize = 8

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

Source

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

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.

§Safety

The caller must guarantee that:

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

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

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
  • output: Destination byte buffer.
  • index: Start byte index in output.
  • value: Value to encode.
§Safety

The caller must guarantee that:

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

impl BinaryCodec<i128, BigEndian>

Source

pub const REQUIRED_MIN_BUFFER_LEN: usize = 16

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

Source

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

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.

§Safety

The caller must guarantee that:

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

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

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
  • output: Destination byte buffer.
  • index: Start byte index in output.
  • value: Value to encode.
§Safety

The caller must guarantee that:

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

impl BinaryCodec<i128, LittleEndian>

Source

pub const REQUIRED_MIN_BUFFER_LEN: usize = 16

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

Source

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

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.

§Safety

The caller must guarantee that:

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

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

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
  • output: Destination byte buffer.
  • index: Start byte index in output.
  • value: Value to encode.
§Safety

The caller must guarantee that:

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

impl BinaryCodec<f32, BigEndian>

Source

pub const REQUIRED_MIN_BUFFER_LEN: usize = 4

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

Source

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

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.

§Safety

The caller must guarantee that:

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

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

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
  • output: Destination byte buffer.
  • index: Start byte index in output.
  • value: Floating-point value to encode.
§Safety

The caller must guarantee that:

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

impl BinaryCodec<f32, LittleEndian>

Source

pub const REQUIRED_MIN_BUFFER_LEN: usize = 4

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

Source

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

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.

§Safety

The caller must guarantee that:

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

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

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
  • output: Destination byte buffer.
  • index: Start byte index in output.
  • value: Floating-point value to encode.
§Safety

The caller must guarantee that:

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

impl BinaryCodec<f64, BigEndian>

Source

pub const REQUIRED_MIN_BUFFER_LEN: usize = 8

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

Source

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

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.

§Safety

The caller must guarantee that:

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

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

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
  • output: Destination byte buffer.
  • index: Start byte index in output.
  • value: Floating-point value to encode.
§Safety

The caller must guarantee that:

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

impl BinaryCodec<f64, LittleEndian>

Source

pub const REQUIRED_MIN_BUFFER_LEN: usize = 8

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

Source

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

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.

§Safety

The caller must guarantee that:

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

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

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
  • output: Destination byte buffer.
  • index: Start byte index in output.
  • value: Floating-point value to encode.
§Safety

The caller must guarantee that:

  • index + Self::REQUIRED_MIN_BUFFER_LEN <= output.len()
  • output[index..index + Self::REQUIRED_MIN_BUFFER_LEN] 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<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: 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: Copy, O: Copy> Copy for BinaryCodec<T, O>

Source§

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

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.