Files
Trac3r-rust/doc/deflate/index.html
2020-01-23 23:13:36 -08:00

51 lines
10 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../dark.css"><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><script src="../storage.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="shortcut icon" href="../favicon.ico"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></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"><div class="sidebar-menu">&#9776;</div><a href='../deflate/index.html'><div class='logo-container'><img src='../rust-logo.png' alt='logo'></div></a><p class='location'>Crate deflate</p><div class="sidebar-elems"><a id='all-types' href='all.html'><p>See all deflate's items</p></a><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></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../theme.js"></script><nav class="sub"><form class="search-form js-only"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"></div><a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><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'>&#x2212;</span>]</a></span><a class='srclink' href='../src/deflate/lib.rs.html#1-495' title='goto source code'>[src]</a></span><span class='in-band'>Crate <a class="mod" href=''>deflate</a></span></h1><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>
<div class="example-wrap"><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&quot;Some data&quot;</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></div>
<h2 id="using-a-writer" class="section-header"><a href="#using-a-writer">Using a writer:</a></h2>
<div class="example-wrap"><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&quot;This is some test data&quot;</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">&quot;Write error!&quot;</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">&quot;Failed to finish compression!&quot;</span>);</pre></div>
</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='deflate::write mod'>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='deflate::CompressionOptions struct'>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='deflate::Compression enum'>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='deflate::MatchingType enum'>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='deflate::SpecialOptions enum'>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='deflate::deflate_bytes fn'>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='deflate::deflate_bytes_conf fn'>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='deflate::deflate_bytes_zlib fn'>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='deflate::deflate_bytes_zlib_conf fn'>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><kbd>?</kbd></dt><dd>Show this help dialog</dd><dt><kbd>S</kbd></dt><dd>Focus the search field</dd><dt><kbd></kbd></dt><dd>Move up in search results</dd><dt><kbd></kbd></dt><dd>Move down in search results</dd><dt><kbd></kbd></dt><dd>Switch tab</dd><dt><kbd>&#9166;</kbd></dt><dd>Go to active search result</dd><dt><kbd>+</kbd></dt><dd>Expand all sections</dd><dt><kbd>-</kbd></dt><dd>Collapse 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><p>Search multiple things at once by splitting your query with comma (e.g., <code>str,u8</code> or <code>String,struct:Vec,test</code>)</p></div></div></aside><script>window.rootPath = "../";window.currentCrate = "deflate";</script><script src="../aliases.js"></script><script src="../main.js"></script><script defer src="../search-index.js"></script></body></html>