Module bit_util

Module bit_util 

Source
Expand description

Utils for working with bits

Structsยง

U64UnalignedSlice ๐Ÿ”’
Centralized structure to handle a mutable u8 slice as a mutable u64 pointer.

Functionsยง

align_to_byte ๐Ÿ”’
Align to byte boundary by applying operation to bits before the next byte boundary.
apply_bitwise_binary_op
Applies a bitwise operation relative to another bit-packed byte slice (right) in place
apply_bitwise_unary_op
Apply a bitwise operation to a mutable buffer, updating it in place.
byte_aligned_bitwise_bin_op_helper ๐Ÿ”’
Perform bitwise binary operation on byte-aligned buffers (i.e. not offsetting into a middle of a byte).
byte_aligned_bitwise_unary_op_helper ๐Ÿ”’
Perform bitwise unary operation on byte-aligned buffer.
ceil
Returns the ceil of value/divisor
get_bit
Returns whether bit at position i in data is set or not
get_bit_rawโš 
Returns whether bit at position i in data is set or not.
get_remainder_bits ๐Ÿ”’
Read remainder bits from a slice.
handle_mutable_buffer_remainder ๐Ÿ”’
Handle remainder bits (< 64 bits) for binary operations.
handle_mutable_buffer_remainder_unary ๐Ÿ”’
Handle remainder bits (< 64 bits) for unary operations.
read_up_to_byte_from_offset ๐Ÿ”’
Read up to 8 bits from a byte slice starting at a given bit offset.
round_upto_multiple_of_64
Returns the nearest number that is >= than num and is a multiple of 64
round_upto_power_of_2
Returns the nearest multiple of factor that is >= than num. Here factor must be a power of 2.
set_bit
Sets bit at position i for data to 1
set_bit_rawโš 
Sets bit at position i for data
set_remainder_bits ๐Ÿ”’
Write remainder bits back to buffer while preserving bits outside the range.
unset_bit
Sets bit at position i for data to 0
unset_bit_rawโš 
Sets bit at position i for data to 0