Expand description
Utils for working with bits
Structsยง
- U64Unaligned
Slice ๐ - 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
iindatais set or not - get_
bit_ โraw - Returns whether bit at position
iindatais 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
>=thannumand is a multiple of 64 - round_
upto_ power_ of_ 2 - Returns the nearest multiple of
factorthat is>=thannum. Herefactormust be a power of 2. - set_bit
- Sets bit at position
ifordatato 1 - set_
bit_ โraw - Sets bit at position
ifordata - set_
remainder_ ๐bits - Write remainder bits back to buffer while preserving bits outside the range.
- unset_
bit - Sets bit at position
ifordatato 0 - unset_
bit_ โraw - Sets bit at position
ifordatato 0