Giter Club home page Giter Club logo

lzzzz's Introduction

lzzzz

Full-featured liblz4 binding for Rust

Crates.io GitHub license Rustdoc Rust FOSSA Status


Usage

Add this to your Cargo.toml:

[dependencies]
lzzzz = "0.6"

API Documentation

Features

  • LZ4
    • Compression (Block / Streaming)
    • Decompression (Block / Streaming)
    • Partial Decompression
    • Custom Dictionary
  • LZ4_HC
    • Compression (Block / Streaming)
    • Partial Compression
    • Custom Dictionary
  • LZ4F
    • Compression
    • Decompression
    • Custom Dictionary
    • Streaming I/O (Read / BufRead / Write)

Examples

Block Mode

use lzzzz::{lz4, lz4_hc, lz4f};

let data = b"The quick brown fox jumps over the lazy dog.";

// LZ4 compression
let mut comp = Vec::new();
lz4::compress_to_vec(data, &mut comp, lz4::ACC_LEVEL_DEFAULT)?;

// LZ4_HC compression
let mut comp = Vec::new();
lz4_hc::compress_to_vec(data, &mut comp, lz4_hc::CLEVEL_DEFAULT)?;

// LZ4/LZ4_HC decompression
let mut decomp = vec![0; data.len()];
lz4::decompress(&comp, &mut decomp)?;

// LZ4F compression
let prefs = lz4f::Preferences::default();
let mut comp = Vec::new();
lz4f::compress_to_vec(data, &mut comp, &prefs)?;

// LZ4F decompression
let mut decomp = Vec::new();
lz4f::decompress_to_vec(&comp, &mut decomp)?;

Streaming Mode

use lzzzz::{lz4, lz4_hc};

let data = b"The quick brown fox jumps over the lazy dog.";

// LZ4 compression
let mut comp = lz4::Compressor::new()?;
let mut buf = Vec::new();
comp.next_to_vec(data, &mut buf, lz4::ACC_LEVEL_DEFAULT)?;

// LZ4_HC compression
let mut comp = lz4_hc::Compressor::new()?;
let mut buf = Vec::new();
comp.next_to_vec(data, &mut buf)?;

// LZ4/LZ4_HC decompression
let mut decomp = lz4::Decompressor::new()?;
let result = decomp.next(&data, data.len())?;
use lzzzz::lz4f::{WriteCompressor, ReadDecompressor, Preferences};
use std::{fs::File, io::prelude::*};

// LZ4F Write-based compression
let mut f = File::create("foo.lz4")?;
let mut w = WriteCompressor::new(&mut f, Preferences::default())?;
w.write_all(b"Hello world!")?;

// LZ4F Read-based decompression
let mut f = File::open("foo.lz4")?;
let mut r = ReadDecompressor::new(&mut f)?;
let mut buf = Vec::new();
r.read_to_end(&mut buf)?;

License

FOSSA Status

lzzzz's People

Contributors

fossabot avatar jean-airoldie avatar picohz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.