add makefile, licence and update README
blockstream: fix multiple calls when EOF
reader: free resources upon io::EOF
This package provides the LZ4 compression algorithm for Hare. It aims to provide a simple, readable and robust implementation with performance as a byproduct.
The LZ4 frame format specifications can be found here: https://github.com/lz4/lz4/blob/dev/doc/lz4_Frame_format.md
make install
git subtree -P vendor/hare-lz4/ add https://git.sr.ht/~pierrec/hare-lz4 main
use compress::lz4;
use io;
fn compress(src: io::handle, dst: io::handle) (void | lz4::error) = {
const hdr = lz4::new_header();
const zw = lz4::new_writer(out, hdr, false, [])?;
defer io::close(&zw)!;
io::copy(&zw, dst)?;
};
use compress::lz4;
use io;
fn decompress(src: io::handle, dst: io::handle) (void | lz4::error) = {
const zr = lz4::new_reader(src)?;
defer io::close(&zr)!;
io::copy(dst, &zr)?;
};
Files can be compressed and decompressed via the utility in cmd/lz4
.
cmd/lz4/: LZ4 de/compressor
Usage: cmd/lz4/ [-cC] files...
-c: compress files (fast, low compression ratio)
-C: compress files (slow, high compression ratio)