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>
impl<O> BinaryCodec<u8, O>
Sourcepub const REQUIRED_MIN_BUFFER_LEN: usize = 1
pub const REQUIRED_MIN_BUFFER_LEN: usize = 1
Minimum number of bytes required to encode or decode this type.
Sourcepub unsafe fn read_unchecked(input: &[u8], index: usize) -> u8
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 ininput.
§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.
Sourcepub unsafe fn write_unchecked(output: &mut [u8], index: usize, value: u8)
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 inoutput.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>
impl<O> BinaryCodec<i8, O>
Sourcepub const REQUIRED_MIN_BUFFER_LEN: usize = 1
pub const REQUIRED_MIN_BUFFER_LEN: usize = 1
Minimum number of bytes required to encode or decode this type.
Sourcepub unsafe fn read_unchecked(input: &[u8], index: usize) -> i8
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 ininput.
§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.
Sourcepub unsafe fn write_unchecked(output: &mut [u8], index: usize, value: i8)
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 inoutput.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>
impl BinaryCodec<u16, BigEndian>
Sourcepub const REQUIRED_MIN_BUFFER_LEN: usize = 2
pub const REQUIRED_MIN_BUFFER_LEN: usize = 2
Minimum number of bytes required to encode or decode this type.
Sourcepub unsafe fn read_unchecked(input: &[u8], index: usize) -> u16
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 ininput.
§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.
Sourcepub unsafe fn write_unchecked(output: &mut [u8], index: usize, value: u16)
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 inoutput.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>
impl BinaryCodec<u16, LittleEndian>
Sourcepub const REQUIRED_MIN_BUFFER_LEN: usize = 2
pub const REQUIRED_MIN_BUFFER_LEN: usize = 2
Minimum number of bytes required to encode or decode this type.
Sourcepub unsafe fn read_unchecked(input: &[u8], index: usize) -> u16
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 ininput.
§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.
Sourcepub unsafe fn write_unchecked(output: &mut [u8], index: usize, value: u16)
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 inoutput.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>
impl BinaryCodec<u32, BigEndian>
Sourcepub const REQUIRED_MIN_BUFFER_LEN: usize = 4
pub const REQUIRED_MIN_BUFFER_LEN: usize = 4
Minimum number of bytes required to encode or decode this type.
Sourcepub unsafe fn read_unchecked(input: &[u8], index: usize) -> u32
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 ininput.
§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.
Sourcepub unsafe fn write_unchecked(output: &mut [u8], index: usize, value: u32)
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 inoutput.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>
impl BinaryCodec<u32, LittleEndian>
Sourcepub const REQUIRED_MIN_BUFFER_LEN: usize = 4
pub const REQUIRED_MIN_BUFFER_LEN: usize = 4
Minimum number of bytes required to encode or decode this type.
Sourcepub unsafe fn read_unchecked(input: &[u8], index: usize) -> u32
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 ininput.
§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.
Sourcepub unsafe fn write_unchecked(output: &mut [u8], index: usize, value: u32)
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 inoutput.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>
impl BinaryCodec<u64, BigEndian>
Sourcepub const REQUIRED_MIN_BUFFER_LEN: usize = 8
pub const REQUIRED_MIN_BUFFER_LEN: usize = 8
Minimum number of bytes required to encode or decode this type.
Sourcepub unsafe fn read_unchecked(input: &[u8], index: usize) -> u64
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 ininput.
§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.
Sourcepub unsafe fn write_unchecked(output: &mut [u8], index: usize, value: u64)
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 inoutput.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>
impl BinaryCodec<u64, LittleEndian>
Sourcepub const REQUIRED_MIN_BUFFER_LEN: usize = 8
pub const REQUIRED_MIN_BUFFER_LEN: usize = 8
Minimum number of bytes required to encode or decode this type.
Sourcepub unsafe fn read_unchecked(input: &[u8], index: usize) -> u64
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 ininput.
§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.
Sourcepub unsafe fn write_unchecked(output: &mut [u8], index: usize, value: u64)
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 inoutput.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>
impl BinaryCodec<u128, BigEndian>
Sourcepub const REQUIRED_MIN_BUFFER_LEN: usize = 16
pub const REQUIRED_MIN_BUFFER_LEN: usize = 16
Minimum number of bytes required to encode or decode this type.
Sourcepub unsafe fn read_unchecked(input: &[u8], index: usize) -> u128
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 ininput.
§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.
Sourcepub unsafe fn write_unchecked(output: &mut [u8], index: usize, value: u128)
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 inoutput.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>
impl BinaryCodec<u128, LittleEndian>
Sourcepub const REQUIRED_MIN_BUFFER_LEN: usize = 16
pub const REQUIRED_MIN_BUFFER_LEN: usize = 16
Minimum number of bytes required to encode or decode this type.
Sourcepub unsafe fn read_unchecked(input: &[u8], index: usize) -> u128
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 ininput.
§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.
Sourcepub unsafe fn write_unchecked(output: &mut [u8], index: usize, value: u128)
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 inoutput.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>
impl BinaryCodec<i16, BigEndian>
Sourcepub const REQUIRED_MIN_BUFFER_LEN: usize = 2
pub const REQUIRED_MIN_BUFFER_LEN: usize = 2
Minimum number of bytes required to encode or decode this type.
Sourcepub unsafe fn read_unchecked(input: &[u8], index: usize) -> i16
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 ininput.
§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.
Sourcepub unsafe fn write_unchecked(output: &mut [u8], index: usize, value: i16)
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 inoutput.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>
impl BinaryCodec<i16, LittleEndian>
Sourcepub const REQUIRED_MIN_BUFFER_LEN: usize = 2
pub const REQUIRED_MIN_BUFFER_LEN: usize = 2
Minimum number of bytes required to encode or decode this type.
Sourcepub unsafe fn read_unchecked(input: &[u8], index: usize) -> i16
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 ininput.
§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.
Sourcepub unsafe fn write_unchecked(output: &mut [u8], index: usize, value: i16)
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 inoutput.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>
impl BinaryCodec<i32, BigEndian>
Sourcepub const REQUIRED_MIN_BUFFER_LEN: usize = 4
pub const REQUIRED_MIN_BUFFER_LEN: usize = 4
Minimum number of bytes required to encode or decode this type.
Sourcepub unsafe fn read_unchecked(input: &[u8], index: usize) -> i32
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 ininput.
§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.
Sourcepub unsafe fn write_unchecked(output: &mut [u8], index: usize, value: i32)
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 inoutput.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>
impl BinaryCodec<i32, LittleEndian>
Sourcepub const REQUIRED_MIN_BUFFER_LEN: usize = 4
pub const REQUIRED_MIN_BUFFER_LEN: usize = 4
Minimum number of bytes required to encode or decode this type.
Sourcepub unsafe fn read_unchecked(input: &[u8], index: usize) -> i32
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 ininput.
§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.
Sourcepub unsafe fn write_unchecked(output: &mut [u8], index: usize, value: i32)
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 inoutput.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>
impl BinaryCodec<i64, BigEndian>
Sourcepub const REQUIRED_MIN_BUFFER_LEN: usize = 8
pub const REQUIRED_MIN_BUFFER_LEN: usize = 8
Minimum number of bytes required to encode or decode this type.
Sourcepub unsafe fn read_unchecked(input: &[u8], index: usize) -> i64
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 ininput.
§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.
Sourcepub unsafe fn write_unchecked(output: &mut [u8], index: usize, value: i64)
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 inoutput.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>
impl BinaryCodec<i64, LittleEndian>
Sourcepub const REQUIRED_MIN_BUFFER_LEN: usize = 8
pub const REQUIRED_MIN_BUFFER_LEN: usize = 8
Minimum number of bytes required to encode or decode this type.
Sourcepub unsafe fn read_unchecked(input: &[u8], index: usize) -> i64
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 ininput.
§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.
Sourcepub unsafe fn write_unchecked(output: &mut [u8], index: usize, value: i64)
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 inoutput.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>
impl BinaryCodec<i128, BigEndian>
Sourcepub const REQUIRED_MIN_BUFFER_LEN: usize = 16
pub const REQUIRED_MIN_BUFFER_LEN: usize = 16
Minimum number of bytes required to encode or decode this type.
Sourcepub unsafe fn read_unchecked(input: &[u8], index: usize) -> i128
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 ininput.
§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.
Sourcepub unsafe fn write_unchecked(output: &mut [u8], index: usize, value: i128)
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 inoutput.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>
impl BinaryCodec<i128, LittleEndian>
Sourcepub const REQUIRED_MIN_BUFFER_LEN: usize = 16
pub const REQUIRED_MIN_BUFFER_LEN: usize = 16
Minimum number of bytes required to encode or decode this type.
Sourcepub unsafe fn read_unchecked(input: &[u8], index: usize) -> i128
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 ininput.
§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.
Sourcepub unsafe fn write_unchecked(output: &mut [u8], index: usize, value: i128)
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 inoutput.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>
impl BinaryCodec<f32, BigEndian>
Sourcepub const REQUIRED_MIN_BUFFER_LEN: usize = 4
pub const REQUIRED_MIN_BUFFER_LEN: usize = 4
Minimum number of bytes required to encode or decode this type.
Sourcepub unsafe fn read_unchecked(input: &[u8], index: usize) -> f32
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 ininput.
§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.
Sourcepub unsafe fn write_unchecked(output: &mut [u8], index: usize, value: f32)
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 inoutput.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>
impl BinaryCodec<f32, LittleEndian>
Sourcepub const REQUIRED_MIN_BUFFER_LEN: usize = 4
pub const REQUIRED_MIN_BUFFER_LEN: usize = 4
Minimum number of bytes required to encode or decode this type.
Sourcepub unsafe fn read_unchecked(input: &[u8], index: usize) -> f32
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 ininput.
§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.
Sourcepub unsafe fn write_unchecked(output: &mut [u8], index: usize, value: f32)
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 inoutput.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>
impl BinaryCodec<f64, BigEndian>
Sourcepub const REQUIRED_MIN_BUFFER_LEN: usize = 8
pub const REQUIRED_MIN_BUFFER_LEN: usize = 8
Minimum number of bytes required to encode or decode this type.
Sourcepub unsafe fn read_unchecked(input: &[u8], index: usize) -> f64
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 ininput.
§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.
Sourcepub unsafe fn write_unchecked(output: &mut [u8], index: usize, value: f64)
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 inoutput.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>
impl BinaryCodec<f64, LittleEndian>
Sourcepub const REQUIRED_MIN_BUFFER_LEN: usize = 8
pub const REQUIRED_MIN_BUFFER_LEN: usize = 8
Minimum number of bytes required to encode or decode this type.
Sourcepub unsafe fn read_unchecked(input: &[u8], index: usize) -> f64
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 ininput.
§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.
Sourcepub unsafe fn write_unchecked(output: &mut [u8], index: usize, value: f64)
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 inoutput.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>
impl<T: Clone, O: Clone> Clone for BinaryCodec<T, O>
Source§fn clone(&self) -> BinaryCodec<T, O>
fn clone(&self) -> BinaryCodec<T, O>
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, O: Default> Default for BinaryCodec<T, O>
impl<T: Default, O: Default> Default for BinaryCodec<T, O>
Source§fn default() -> BinaryCodec<T, O>
fn default() -> BinaryCodec<T, O>
Source§impl<T: PartialEq, O: PartialEq> PartialEq for BinaryCodec<T, O>
impl<T: PartialEq, O: PartialEq> PartialEq for BinaryCodec<T, O>
Source§fn eq(&self, other: &BinaryCodec<T, O>) -> bool
fn eq(&self, other: &BinaryCodec<T, O>) -> bool
self and other values to be equal, and is used by ==.