Skip to main content

align_to_byte

Function align_to_byte 

Source
fn align_to_byte<F>(
    buffer: &mut [u8],
    op: &mut F,
    offset_in_bits: usize,
    remaining_len_in_bits: usize,
)
where F: FnMut(u64) -> u64,
Expand description

Align to byte boundary by applying operation to bits before the next byte boundary.

This function handles non-byte-aligned operations by processing bits from the current position up to the next byte boundary, while preserving all other bits in the byte.

ยงArguments

  • op - Unary operation to apply
  • buffer - The mutable buffer to modify
  • offset_in_bits - Starting bit offset (not byte-aligned)
  • remaining_len_in_bits - Number of bits still to process starting at offset_in_bits. When this is smaller than the number of bits left in the byte, the trailing bits of the byte are left untouched.