34 lines
6.3 KiB
HTML
34 lines
6.3 KiB
HTML
<!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="ZSTD_compressStream2() : Requires v1.4.0+ Behaves about the same as ZSTD_compressStream, with additional control on end directive."><title>ZSTD_compressStream2 in zstd_sys - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="zstd_sys" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">ZSTD_compressStream2</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../zstd_sys/index.html">zstd_<wbr>sys</a><span class="version">2.0.16+zstd.1.5.7</span></h2></div><div class="sidebar-elems"><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="index.html">zstd_sys</a></div><h1>Function <span class="fn">ZSTD_<wbr>compress<wbr>Stream2</span> <button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/zstd_sys/bindings_zstd.rs.html#388-393">Source</a> </span></div><pre class="rust item-decl"><code>pub unsafe extern "C" fn ZSTD_compressStream2(
|
||
cctx: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.pointer.html">*mut </a><a class="type" href="type.ZSTD_CCtx.html" title="type zstd_sys::ZSTD_CCtx">ZSTD_CCtx</a>,
|
||
output: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.pointer.html">*mut </a><a class="type" href="type.ZSTD_outBuffer.html" title="type zstd_sys::ZSTD_outBuffer">ZSTD_outBuffer</a>,
|
||
input: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.pointer.html">*mut </a><a class="type" href="type.ZSTD_inBuffer.html" title="type zstd_sys::ZSTD_inBuffer">ZSTD_inBuffer</a>,
|
||
endOp: <a class="enum" href="enum.ZSTD_EndDirective.html" title="enum zstd_sys::ZSTD_EndDirective">ZSTD_EndDirective</a>,
|
||
) -> <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.usize.html">usize</a></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>ZSTD_compressStream2() : Requires v1.4.0+
|
||
Behaves about the same as ZSTD_compressStream, with additional control on end directive.</p>
|
||
<ul>
|
||
<li>Compression parameters are pushed into CCtx before starting compression, using ZSTD_CCtx_set*()</li>
|
||
<li>Compression parameters cannot be changed once compression is started (save a list of exceptions in multi-threading mode)</li>
|
||
<li>output->pos must be <= dstCapacity, input->pos must be <= srcSize</li>
|
||
<li>output->pos and input->pos will be updated. They are guaranteed to remain below their respective limit.</li>
|
||
<li>endOp must be a valid directive</li>
|
||
<li>When nbWorkers==0 (default), function is blocking : it completes its job before returning to caller.</li>
|
||
<li>When nbWorkers>=1, function is non-blocking : it copies a portion of input, distributes jobs to internal worker threads, flush to output whatever is available,
|
||
and then immediately returns, just indicating that there is some data remaining to be flushed.
|
||
The function nonetheless guarantees forward progress : it will return only after it reads or write at least 1+ byte.</li>
|
||
<li>Exception : if the first call requests a ZSTD_e_end directive and provides enough dstCapacity, the function delegates to ZSTD_compress2() which is always blocking.</li>
|
||
<li>@return provides a minimum amount of data remaining to be flushed from internal buffers
|
||
or an error code, which can be tested using ZSTD_isError().
|
||
if @return != 0, flush is not fully completed, there is still some data left within internal buffers.
|
||
This is useful for ZSTD_e_flush, since in this case more flushes are necessary to empty all buffers.
|
||
For ZSTD_e_end, @return == 0 when internal buffers are fully flushed and frame is completed.</li>
|
||
<li>after a ZSTD_e_end directive, if internal buffer is not fully flushed (@return != 0),
|
||
only ZSTD_e_end or ZSTD_e_flush operations are allowed.
|
||
Before starting a new compression job, or changing compression parameters,
|
||
it is required to fully flush internal buffers.</li>
|
||
<li>note: if an operation ends with an error, it may leave @cctx in an undefined state.
|
||
Therefore, it’s UB to invoke ZSTD_compressStream2() of ZSTD_compressStream() on such a state.
|
||
In order to be re-employed after an error, a state must be reset,
|
||
which can be done explicitly (ZSTD_CCtx_reset()),
|
||
or is sometimes implied by methods starting a new compression job (ZSTD_initCStream(), ZSTD_compressCCtx())</li>
|
||
</ul>
|
||
</div></details></section></div></main></body></html> |