Coder Social home page Coder Social logo

ovibos / flate2-rs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rust-lang/flate2-rs

0.0 1.0 0.0 1.14 MB

FLATE, Gzip, and Zlib bindings for Rust

Home Page: http://alexcrichton.com/flate2-rs

License: Apache License 2.0

Rust 41.40% C 58.60%

flate2-rs's Introduction

flate2

Build Status Build status Crates.io Documentation

A streaming compression/decompression library for Rust. The underlying implementation by default uses miniz but can optionally be configured to use the system zlib, if available.

Supported formats:

  • deflate
  • zlib
  • gzip
# Cargo.toml
[dependencies]
flate2 = "0.2"

Using zlib instead of miniz:

[dependencies]
flate2 = { version = "0.2", features = ["zlib"], default-features = false }

Compression

extern crate flate2;

use std::io::prelude::*;
use flate2::Compression;
use flate2::write::ZlibEncoder;

fn main() {
    let mut e = ZlibEncoder::new(Vec::new(), Compression::Default);
    e.write(b"foo");
    e.write(b"bar");
    let compressed_bytes = e.finish();
}

Decompression

extern crate flate2;

use std::io::prelude::*;
use flate2::read::GzDecoder;

fn main() {
    let mut d = GzDecoder::new("...".as_bytes()).unwrap();
    let mut s = String::new();
    d.read_to_string(&mut s).unwrap();
    println!("{}", s);
}

License

flate2-rs is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses.

See LICENSE-APACHE, and LICENSE-MIT for details.

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.