2017-07-14 23:30:16 +00:00
<!DOCTYPE html>
< html lang = "en" >
< head >
< meta charset = "utf-8" >
< meta name = "viewport" content = "width=device-width, initial-scale=1.0" >
< meta name = "generator" content = "rustdoc" >
< meta name = "description" content = "API documentation for the Rust `deflate` crate." >
< meta name = "keywords" content = "rust, rustlang, rust-lang, deflate" >
< title > deflate - Rust< / title >
< link rel = "stylesheet" type = "text/css" href = "../normalize.css" >
< link rel = "stylesheet" type = "text/css" href = "../rustdoc.css" >
< link rel = "stylesheet" type = "text/css" href = "../main.css" >
< / head >
< body class = "rustdoc mod" >
<!-- [if lte IE 8]>
< div class = "warning" >
This old browser is unsupported and will most likely display funky
things.
< / div >
<![endif]-->
< nav class = "sidebar" >
< p class = 'location' > Crate deflate< / p > < div class = "block items" > < ul > < li > < a href = "#modules" > Modules< / a > < / li > < li > < a href = "#structs" > Structs< / a > < / li > < li > < a href = "#enums" > Enums< / a > < / li > < li > < a href = "#functions" > Functions< / a > < / li > < / ul > < / div > < p class = 'location' > < / p > < script > window . sidebarCurrent = { name : 'deflate' , ty : 'mod' , relpath : '../' } ; < / script >
< / nav >
< nav class = "sub" >
< form class = "search-form js-only" >
< div class = "search-container" >
< input class = "search-input" name = "search"
autocomplete="off"
placeholder="Click or press ‘ S’ to search, ‘ ?’ for more options…"
type="search">
< / div >
< / form >
< / nav >
< section id = 'main' class = "content" >
< h1 class = 'fqn' > < span class = 'in-band' > Crate < a class = "mod" href = '' > deflate< / a > < / span > < span class = 'out-of-band' > < span id = 'render-detail' >
< a id = "toggle-all-docs" href = "javascript:void(0)" title = "collapse all docs" >
[< span class = 'inner' > − < / span > ]
< / a >
2017-07-16 21:37:37 +00:00
< / span > < a class = 'srclink' href = '../src/deflate/lib.rs.html#1-498' title = 'goto source code' > [src]< / a > < / span > < / h1 >
2017-07-14 23:30:16 +00:00
< div class = 'docblock' > < p > An implementation an encoder using < a href = "http://www.gzip.org/zlib/rfc-deflate.html" > DEFLATE< / a >
compression algorightm in pure rust.< / p >
< p > This library provides functions to compress data using the DEFLATE algorithm,
optionally wrapped using the < a href = "https://tools.ietf.org/html/rfc1950" > zlib< / a > or
< a href = "http://www.gzip.org/zlib/rfc-gzip.html" > gzip< / a > formats.
The current implementation is still a bit lacking speed-wise compared to C-libraries
like zlib and miniz.< / p >
< p > The deflate algorithm is an older compression algorithm that is still widely used today,
by e.g html headers, the < code > .png< / code > inage format, the unix < code > gzip< / code > program and commonly in < code > .zip< / code >
files. The < code > zlib< / code > and < code > gzip< / code > formats are wrappers around DEFLATE-compressed data, containing
some extra metadata and a checksum to validate the integrity of the raw data.< / p >
< p > The deflate algorithm does not perform as well as newer algorhitms used in file formats such as
< code > .7z< / code > , < code > .rar< / code > , < code > .xz< / code > and < code > .bz2< / code > , and is thus not the ideal choice for applications where
the < code > DEFLATE< / code > format (with or without wrappers) is not required.< / p >
< p > Support for the gzip wrapper (the wrapper that is used in < code > .gz< / code > files) is disabled by default,
but can be enabled with the < code > gzip< / code > feature.< / p >
< p > As this library is still in development, the compression output may change slightly
between versions.< / p >
< h1 id = 'examples' class = 'section-header' > < a href = '#examples' > Examples:< / a > < / h1 >
< h2 id = 'simple-compression-function' class = 'section-header' > < a href = '#simple-compression-function' > Simple compression function:< / a > < / h2 >
< pre class = "rust rust-example-rendered" >
< span class = "kw" > use< / span > < span class = "ident" > deflate< / span > ::< span class = "ident" > deflate_bytes< / span > ;
< span class = "kw" > let< / span > < span class = "ident" > data< / span > < span class = "op" > =< / span > < span class = "string" > b" Some data" < / span > ;
< span class = "kw" > let< / span > < span class = "ident" > compressed< / span > < span class = "op" > =< / span > < span class = "ident" > deflate_bytes< / span > (< span class = "ident" > data< / span > );< / pre >
< h2 id = 'using-a-writer' class = 'section-header' > < a href = '#using-a-writer' > Using a writer:< / a > < / h2 >
< pre class = "rust rust-example-rendered" >
< span class = "kw" > use< / span > < span class = "ident" > std< / span > ::< span class = "ident" > io< / span > ::< span class = "ident" > Write< / span > ;
< span class = "kw" > use< / span > < span class = "ident" > deflate< / span > ::< span class = "ident" > Compression< / span > ;
< span class = "kw" > use< / span > < span class = "ident" > deflate< / span > ::< span class = "ident" > write< / span > ::< span class = "ident" > ZlibEncoder< / span > ;
< span class = "kw" > let< / span > < span class = "ident" > data< / span > < span class = "op" > =< / span > < span class = "string" > b" This is some test data" < / span > ;
< span class = "kw" > let< / span > < span class = "kw-2" > mut< / span > < span class = "ident" > encoder< / span > < span class = "op" > =< / span > < span class = "ident" > ZlibEncoder< / span > ::< span class = "ident" > new< / span > (< span class = "ident" > Vec< / span > ::< span class = "ident" > new< / span > (), < span class = "ident" > Compression< / span > ::< span class = "ident" > Default< / span > );
< span class = "ident" > encoder< / span > .< span class = "ident" > write_all< / span > (< span class = "ident" > data< / span > ).< span class = "ident" > expect< / span > (< span class = "string" > " Write error!" < / span > );
< span class = "kw" > let< / span > < span class = "ident" > compressed_data< / span > < span class = "op" > =< / span > < span class = "ident" > encoder< / span > .< span class = "ident" > finish< / span > ().< span class = "ident" > expect< / span > (< span class = "string" > " Failed to finish compression!" < / span > );< / pre >
< / div > < h2 id = 'modules' class = 'section-header' > < a href = "#modules" > Modules< / a > < / h2 >
< table >
< tr class = ' module-item' >
< td > < a class = "mod" href = "write/index.html"
title='mod deflate::write'>write< / a > < / td >
< td class = 'docblock-short' >
< p > Encoders implementing a < code > Write< / code > interface.< / p >
< / td >
< / tr > < / table > < h2 id = 'structs' class = 'section-header' > < a href = "#structs" > Structs< / a > < / h2 >
< table >
< tr class = ' module-item' >
< td > < a class = "struct" href = "struct.CompressionOptions.html"
title='struct deflate::CompressionOptions'>CompressionOptions< / a > < / td >
< td class = 'docblock-short' >
< p > A struct describing the options for a compressor or compression function.< / p >
< / td >
< / tr > < / table > < h2 id = 'enums' class = 'section-header' > < a href = "#enums" > Enums< / a > < / h2 >
< table >
< tr class = ' module-item' >
< td > < a class = "enum" href = "enum.Compression.html"
title='enum deflate::Compression'>Compression< / a > < / td >
< td class = 'docblock-short' >
< p > An enum describing the level of compression to be used by the encoder< / p >
< / td >
< / tr >
< tr class = ' module-item' >
< td > < a class = "enum" href = "enum.MatchingType.html"
title='enum deflate::MatchingType'>MatchingType< / a > < / td >
< td class = 'docblock-short' >
< p > An enum describing whether we use lazy or greedy matching.< / p >
< / td >
< / tr >
< tr class = ' module-item' >
< td > < a class = "enum" href = "enum.SpecialOptions.html"
title='enum deflate::SpecialOptions'>SpecialOptions< / a > < / td >
< td class = 'docblock-short' >
< p > Enum allowing some special options (not implemented yet)!< / p >
< / td >
< / tr > < / table > < h2 id = 'functions' class = 'section-header' > < a href = "#functions" > Functions< / a > < / h2 >
< table >
< tr class = ' module-item' >
< td > < a class = "fn" href = "fn.deflate_bytes.html"
title='fn deflate::deflate_bytes'>deflate_bytes< / a > < / td >
< td class = 'docblock-short' >
< p > Compress the given slice of bytes with DEFLATE compression using the default compression
level.< / p >
< / td >
< / tr >
< tr class = ' module-item' >
< td > < a class = "fn" href = "fn.deflate_bytes_conf.html"
title='fn deflate::deflate_bytes_conf'>deflate_bytes_conf< / a > < / td >
< td class = 'docblock-short' >
< p > Compress the given slice of bytes with DEFLATE compression.< / p >
< / td >
< / tr >
< tr class = ' module-item' >
< td > < a class = "fn" href = "fn.deflate_bytes_zlib.html"
title='fn deflate::deflate_bytes_zlib'>deflate_bytes_zlib< / a > < / td >
< td class = 'docblock-short' >
< p > Compress the given slice of bytes with DEFLATE compression, including a zlib header and trailer,
using the default compression level.< / p >
< / td >
< / tr >
< tr class = ' module-item' >
< td > < a class = "fn" href = "fn.deflate_bytes_zlib_conf.html"
title='fn deflate::deflate_bytes_zlib_conf'>deflate_bytes_zlib_conf< / a > < / td >
< td class = 'docblock-short' >
< p > Compress the given slice of bytes with DEFLATE compression, including a zlib header and trailer.< / p >
< / td >
< / tr > < / table > < / section >
< section id = 'search' class = "content hidden" > < / section >
< section class = "footer" > < / section >
< aside id = "help" class = "hidden" >
< div >
< h1 class = "hidden" > Help< / h1 >
< div class = "shortcuts" >
< h2 > Keyboard Shortcuts< / h2 >
< dl >
< dt > ?< / dt >
< dd > Show this help dialog< / dd >
< dt > S< / dt >
< dd > Focus the search field< / dd >
< dt > ⇤ < / dt >
< dd > Move up in search results< / dd >
< dt > ⇥ < / dt >
< dd > Move down in search results< / dd >
< dt > ⏎ < / dt >
< dd > Go to active search result< / dd >
< dt > +< / dt >
< dd > Collapse/expand all sections< / dd >
< / dl >
< / div >
< div class = "infos" >
< h2 > Search Tricks< / h2 >
< p >
Prefix searches with a type followed by a colon (e.g.
< code > fn:< / code > ) to restrict the search to a given type.
< / p >
< p >
Accepted types are: < code > fn< / code > , < code > mod< / code > ,
< code > struct< / code > , < code > enum< / code > ,
< code > trait< / code > , < code > type< / code > , < code > macro< / code > ,
and < code > const< / code > .
< / p >
< p >
Search functions by type signature (e.g.
< code > vec -> usize< / code > or < code > * -> vec< / code > )
< / p >
< / div >
< / div >
< / aside >
< script >
window.rootPath = "../";
window.currentCrate = "deflate";
< / script >
< script src = "../main.js" > < / script >
< script defer src = "../search-index.js" > < / script >
< / body >
< / html >