Expand description
Utility functions for analyzing and processing bit-packed data.
This module provides low-level utilities for:
- Size estimation and compression
- Bit manipulation and ordering
- Bitstream reader/writer creation and management
§Core Functions
size_estimate
: Estimates compressed data size based on LZ matches and entropyget_zstd_compressed_size
: Calculates actual compressed size using zstandardcalculate_file_entropy
: Computes Shannon entropy of input datareverse_bits
: Reverses bits in a u64 value
§Bitstream Utilities
create_bit_reader
: Creates aBitReaderContainer
with specified endiannesscreate_bit_writer
: Creates aBitWriterContainer
with specified endiannesscreate_bit_writer_with_owned_data
: Creates writer containing copied dataget_writer_buffer
: Retrieves underlying buffer from a writerbit_writer_to_reader
: Converts a writer into a reader
§Types
BitReaderContainer
: Wrapper around bit readers supporting both endiansBitWriterContainer
: Wrapper around bit writers supporting both endians
Enums§
- BitReader
Container - Wrapper around the
BitReader
type that allows it to be used with either endian. - BitWriter
Container - Tracks statistics about individual bits in a field
Functions§
- bit_
writer_ to_ reader - Converts a
BitWriterContainer
instance into aBitReaderContainer
instance. - calculate_
file_ entropy - Calculates the entropy of a given input
- create_
bit_ reader - Creates a
BitReaderContainer
instance based on the givenBitOrder
. - create_
bit_ writer - Creates a
BitWriterContainer
instance based on the givenBitOrder
. - create_
bit_ writer_ with_ owned_ data - Creates a
BitWriterContainer
instance based on the givenBitOrder
. This copies the supplied data into a new buffer, which is then owned by the container. - get_
writer_ buffer - Retrieves the buffer behind a
BitWriterContainer
instance. - get_
zstd_ compressed_ size - Determines the actual size of the compressed data by compressing with a realistic compressor.
- reverse_
bits - Reverses the bits of a u64 value
- size_
estimate - Estimate size of a compressed data based on precalculated LZ matches and entropy