Compressing
Basic (and naive) LZW and Huffman compression algorithms in Rust.
Install / Use
/learn @lffg/CompressingREADME
Naive implementation of the LZW and Huffman compression algorithms.
To run, install the Rust toolchain. Cargo may be used to compile the source.
Example,
$ cargo run
Usage: cmpr [OPTIONS] -a <ALGORITHM> <COMMAND>
Commands:
compress
decompress
help Print this message or the help of the given subcommand(s)
Options:
-a <ALGORITHM> The algorithm to use for compress or decompress [possible values: lzw, huffman]
--stats Whether the program should show statistics
-h, --help Print help
-V, --version Print version
Compress a file using the LZW algorithm (assuming cargo build --release):
$ ./target/release/cmpr -a lzw --stats compress -o Cargo.lock.lzw Cargo.lock
done.
in 1 ms
saved 35.10%
Decompress the same file:
$ ./target/release/cmpr -a lzw --stats decompress -o recovered-Cargo.lock Cargo.lock.lzw
done.
in 0 ms
The script cmp.sh may be used to test the compression algorithm by
compressing, decompressing and comparing with the original file. E.g.,
$ ./cmp.sh Cargo.lock
Finished release [optimized] target(s) in 0.06s
cmpr 0.1.0
compressing [Cargo.lock] into [Cargo.lock.cmp]...
done.
in 1 ms
saved 35.10%
decompressing [Cargo.lock.cmp] into [recovered-Cargo.lock]...
done.
in 2 ms
ok
Related Skills
node-connect
347.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
108.0kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
347.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
