read_up_to_byte_from_offset

Function read_up_to_byte_from_offset 

Source
pub(crate) fn read_up_to_byte_from_offset(
    slice: &[u8],
    number_of_bits_to_read: usize,
    bit_offset: usize,
) -> u8
Expand description

Read up to 8 bits from a byte slice starting at a given bit offset.

§Arguments

  • slice - The byte slice to read from
  • number_of_bits_to_read - Number of bits to read (must be < 8)
  • bit_offset - Starting bit offset within the first byte (must be < 8)

§Returns

A u8 containing the requested bits in the least significant positions

§Panics

  • Panics if number_of_bits_to_read is 0 or >= 8
  • Panics if bit_offset is >= 8
  • Panics if slice is empty or too small to read the requested bits