# [−][src]Crate deflate

An implementation an encoder using DEFLATE compression algorightm in pure rust.

This library provides functions to compress data using the DEFLATE algorithm, optionally wrapped using the zlib or gzip formats. The current implementation is still a bit lacking speed-wise compared to C-libraries like zlib and miniz.

The deflate algorithm is an older compression algorithm that is still widely used today, by e.g html headers, the `.png` inage format, the unix `gzip` program and commonly in `.zip` files. The `zlib` and `gzip` formats are wrappers around DEFLATE-compressed data, containing some extra metadata and a checksum to validate the integrity of the raw data.

The deflate algorithm does not perform as well as newer algorhitms used in file formats such as `.7z`, `.rar`, `.xz` and `.bz2`, and is thus not the ideal choice for applications where the `DEFLATE` format (with or without wrappers) is not required.

Support for the gzip wrapper (the wrapper that is used in `.gz` files) is disabled by default, but can be enabled with the `gzip` feature.

As this library is still in development, the compression output may change slightly between versions.

# Examples:

## Simple compression function:

    use deflate::deflate_bytes;

    let data = b"Some data";
    let compressed = deflate_bytes(data);

## Using a writer:

    use std::io::Write;

    use deflate::Compression;
    use deflate::write::ZlibEncoder;

    let data = b"This is some test data";
    let mut encoder = ZlibEncoder::new(Vec::new(), Compression::Default);
    encoder.write_all(data).expect("Write error!");
    let compressed_data = encoder.finish().expect("Failed to finish compression!");

## Modules

write | Encoders implementing a `Write` interface.

## Structs

CompressionOptions | A struct describing the options for a compressor or compression function.

## Enums

Compression | An enum describing the level of compression to be used by the encoder
MatchingType | An enum describing whether we use lazy or greedy matching.
SpecialOptions | Enum allowing some special options (not implemented yet)!

## Functions

deflate_bytes | Compress the given slice of bytes with DEFLATE compression using the default compression level.
deflate_bytes_conf | Compress the given slice of bytes with DEFLATE compression.
deflate_bytes_zlib | Compress the given slice of bytes with DEFLATE compression, including a zlib header and trailer, using the default compression level.
deflate_bytes_zlib_conf | Compress the given slice of bytes with DEFLATE compression, including a zlib header and trailer.

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g., `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g., `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g., `str,u8` or `String,struct:Vec,test`)