File: README.md

package info (click to toggle)
rust-rust-lzma 0.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 372 kB
  • sloc: makefile: 4
file content (41 lines) | stat: -rw-r--r-- 1,353 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# rust-lzma [![Build Status](https://travis-ci.org/fpgaminer/rust-lzma.svg?branch=master)](https://travis-ci.org/fpgaminer/rust-lzma) [![Crates.io](https://img.shields.io/crates/v/rust-lzma.svg)](https://crates.io/crates/rust-lzma) #

[Documentation](https://docs.rs/rust-lzma/)

This crate provides a simple interface to liblzma.  LZMA is more commonly known
as XZ or 7zip, (as in, files with the `.xz` or `.7z` file extension). LZMA
compression is fast and aggressive, compressing better than bzip2.  liblzma
implements the XZ variant, so it can read and write `.xz` files/streams.

Two interfaces are provided.  `LzmaReader`/`LzmaWriter` are generic Readers and
Writers that can be composed with other `Read`/`Write` interfaces.  For example,
wrap them around a `File` and you can write data to a file while compressing it
on the fly, or stream in an `xz` file from disk.

`compress`/`decompress` are easy to use functions for simple use cases.

See the documentation for details on usage.


## Example ##
Cargo.toml:
```toml
[dependencies]
rust-lzma = "0.5"
```
main.rs:
```Rust
extern crate lzma;

use lzma::LzmaWriter;
use std::io::prelude::*;
use std::fs::File;

fn main() {
	let f = File::create("foo.xz").unwrap();
	let mut f = LzmaWriter::new_compressor(f, 6).unwrap();

	write!(f, "It's a small world!").unwrap();
	f.finish().unwrap();
}
```