#huffman-coding #compression #decompression

bin+lib huff

Example compression/decompression CLI software based on the huff_coding crate

3 stable releases

1.0.6 Mar 3, 2021
1.0.5 Feb 28, 2021
1.0.4 Feb 27, 2021
1.0.3 Jan 21, 2021
1.0.2 Jan 20, 2021

#51 in Compression

Download history 53/week @ 2021-01-19 8/week @ 2021-01-26 12/week @ 2021-02-02 5/week @ 2021-02-09 42/week @ 2021-02-16 37/week @ 2021-02-23 20/week @ 2021-03-02 5/week @ 2021-03-09 14/week @ 2021-03-23 21/week @ 2021-03-30 8/week @ 2021-04-06

59 downloads per month

GPL-2.0-or-later

105KB
1.5K SLoC

huff

Crate

License

Example compression/decompression CLI software based on the huff_coding crate.

Usage

huff [FLAGS] [OPTIONS] <SRC_FILE> [DST_FILE]

Args

<SRC_FILE>    
<DST_FILE>    [default: ./SRC_FILE.hff]

Options

-b, --block-size <SIZE>
        Set how many bytes can be loaded from the file at one time
        Possible units: 
            K/Ki -> Kilobytes/Kibibytes
            M/Mi -> Megabytes/Mebibytes
            G/Gi -> Gigabytes/Gibibytes
         [default: 2G]

Flags

-d, --decompress    
        Decompresses the hff SRC_FILE into DST_FILE.hff
            
-n, --noask         
        Omits asking if should replace existing DST_FILE

-r, --replace       
        Deletes SRC_FILE upon completion

-t, --time          
        Prints how long it took to finish
-h, --help          
        Prints help information

-V, --version       
        Prints version information

File format

The hff file format is encoded as follows:

  1. A byte containing the number of bits used for padding:
    • first 4 bits store the HuffTree's padding bits
    • the remaining bits store the compressed data's padding bits
  2. 4 byte number representing the length (in bytes) of the stored HuffTree
  3. A HuffTree, used to compress the file, represented in binary (see HuffTree::try_from_bin)
  4. The actual compressed data

Dependencies

~2MB
~34K SLoC