Skip to main content

zstd_sys/
bindings_zstd_std.rs

1// Copyright 2024 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Generated by third_party/rust_crates/forks/zstd-sys/bindgen.sh using bindgen 0.72.0
6
7pub const ZSTD_VERSION_MAJOR: u32 = 1;
8pub const ZSTD_VERSION_MINOR: u32 = 5;
9pub const ZSTD_VERSION_RELEASE: u32 = 7;
10pub const ZSTD_VERSION_NUMBER: u32 = 10507;
11pub const ZSTD_CLEVEL_DEFAULT: u32 = 3;
12pub const ZSTD_MAGICNUMBER: u32 = 4247762216;
13pub const ZSTD_MAGIC_DICTIONARY: u32 = 3962610743;
14pub const ZSTD_MAGIC_SKIPPABLE_START: u32 = 407710288;
15pub const ZSTD_MAGIC_SKIPPABLE_MASK: u32 = 4294967280;
16pub const ZSTD_BLOCKSIZELOG_MAX: u32 = 17;
17pub const ZSTD_BLOCKSIZE_MAX: u32 = 131072;
18pub const ZSTD_CONTENTSIZE_UNKNOWN: i32 = -1;
19pub const ZSTD_CONTENTSIZE_ERROR: i32 = -2;
20unsafe extern "C" {
21    /// ZSTD_versionNumber() :
22    ///  Return runtime library version, the value is (MAJOR*100*100 + MINOR*100 + RELEASE).
23    pub fn ZSTD_versionNumber() -> ::core::ffi::c_uint;
24}
25unsafe extern "C" {
26    /// ZSTD_versionString() :
27    ///  Return runtime library version, like "1.4.5". Requires v1.3.0+.
28    pub fn ZSTD_versionString() -> *const ::core::ffi::c_char;
29}
30unsafe extern "C" {
31    ///  Simple Core API
32    ////
33    ////*! ZSTD_compress() :
34    ///  Compresses `src` content as a single zstd compressed frame into already allocated `dst`.
35    ///  NOTE: Providing `dstCapacity >= ZSTD_compressBound(srcSize)` guarantees that zstd will have
36    ///        enough space to successfully compress the data.
37    ///  @return : compressed size written into `dst` (<= `dstCapacity),
38    ///            or an error code if it fails (which can be tested using ZSTD_isError()).
39    pub fn ZSTD_compress(
40        dst: *mut ::core::ffi::c_void,
41        dstCapacity: usize,
42        src: *const ::core::ffi::c_void,
43        srcSize: usize,
44        compressionLevel: ::core::ffi::c_int,
45    ) -> usize;
46}
47unsafe extern "C" {
48    /// ZSTD_decompress() :
49    /// `compressedSize` : must be the _exact_ size of some number of compressed and/or skippable frames.
50    ///  Multiple compressed frames can be decompressed at once with this method.
51    ///  The result will be the concatenation of all decompressed frames, back to back.
52    /// `dstCapacity` is an upper bound of originalSize to regenerate.
53    ///  First frame's decompressed size can be extracted using ZSTD_getFrameContentSize().
54    ///  If maximum upper bound isn't known, prefer using streaming mode to decompress data.
55    /// @return : the number of bytes decompressed into `dst` (<= `dstCapacity`),
56    ///           or an errorCode if it fails (which can be tested using ZSTD_isError()).
57    pub fn ZSTD_decompress(
58        dst: *mut ::core::ffi::c_void,
59        dstCapacity: usize,
60        src: *const ::core::ffi::c_void,
61        compressedSize: usize,
62    ) -> usize;
63}
64unsafe extern "C" {
65    pub fn ZSTD_getFrameContentSize(
66        src: *const ::core::ffi::c_void,
67        srcSize: usize,
68    ) -> ::core::ffi::c_ulonglong;
69}
70unsafe extern "C" {
71    /// ZSTD_getDecompressedSize() (obsolete):
72    ///  This function is now obsolete, in favor of ZSTD_getFrameContentSize().
73    ///  Both functions work the same way, but ZSTD_getDecompressedSize() blends
74    ///  "empty", "unknown" and "error" results to the same return value (0),
75    ///  while ZSTD_getFrameContentSize() gives them separate return values.
76    /// @return : decompressed size of `src` frame content _if known and not empty_, 0 otherwise.
77    pub fn ZSTD_getDecompressedSize(
78        src: *const ::core::ffi::c_void,
79        srcSize: usize,
80    ) -> ::core::ffi::c_ulonglong;
81}
82unsafe extern "C" {
83    /// ZSTD_findFrameCompressedSize() : Requires v1.4.0+
84    /// `src` should point to the start of a ZSTD frame or skippable frame.
85    /// `srcSize` must be >= first frame size
86    /// @return : the compressed size of the first frame starting at `src`,
87    ///           suitable to pass as `srcSize` to `ZSTD_decompress` or similar,
88    ///           or an error code if input is invalid
89    ///  Note 1: this method is called _find*() because it's not enough to read the header,
90    ///          it may have to scan through the frame's content, to reach its end.
91    ///  Note 2: this method also works with Skippable Frames. In which case,
92    ///          it returns the size of the complete skippable frame,
93    ///          which is always equal to its content size + 8 bytes for headers.
94    pub fn ZSTD_findFrameCompressedSize(src: *const ::core::ffi::c_void, srcSize: usize) -> usize;
95}
96unsafe extern "C" {
97    pub fn ZSTD_compressBound(srcSize: usize) -> usize;
98}
99unsafe extern "C" {
100    pub fn ZSTD_isError(result: usize) -> ::core::ffi::c_uint;
101}
102unsafe extern "C" {
103    pub fn ZSTD_getErrorCode(functionResult: usize) -> ZSTD_ErrorCode;
104}
105unsafe extern "C" {
106    pub fn ZSTD_getErrorName(result: usize) -> *const ::core::ffi::c_char;
107}
108unsafe extern "C" {
109    pub fn ZSTD_minCLevel() -> ::core::ffi::c_int;
110}
111unsafe extern "C" {
112    pub fn ZSTD_maxCLevel() -> ::core::ffi::c_int;
113}
114unsafe extern "C" {
115    pub fn ZSTD_defaultCLevel() -> ::core::ffi::c_int;
116}
117#[repr(C)]
118#[derive(Debug)]
119pub struct ZSTD_CCtx_s {
120    _unused: [u8; 0],
121}
122///  Explicit context
123pub type ZSTD_CCtx = ZSTD_CCtx_s;
124unsafe extern "C" {
125    pub fn ZSTD_createCCtx() -> *mut ZSTD_CCtx;
126}
127unsafe extern "C" {
128    pub fn ZSTD_freeCCtx(cctx: *mut ZSTD_CCtx) -> usize;
129}
130unsafe extern "C" {
131    /// ZSTD_compressCCtx() :
132    ///  Same as ZSTD_compress(), using an explicit ZSTD_CCtx.
133    ///  Important : in order to mirror `ZSTD_compress()` behavior,
134    ///  this function compresses at the requested compression level,
135    ///  __ignoring any other advanced parameter__ .
136    ///  If any advanced parameter was set using the advanced API,
137    ///  they will all be reset. Only @compressionLevel remains.
138    pub fn ZSTD_compressCCtx(
139        cctx: *mut ZSTD_CCtx,
140        dst: *mut ::core::ffi::c_void,
141        dstCapacity: usize,
142        src: *const ::core::ffi::c_void,
143        srcSize: usize,
144        compressionLevel: ::core::ffi::c_int,
145    ) -> usize;
146}
147#[repr(C)]
148#[derive(Debug)]
149pub struct ZSTD_DCtx_s {
150    _unused: [u8; 0],
151}
152pub type ZSTD_DCtx = ZSTD_DCtx_s;
153unsafe extern "C" {
154    pub fn ZSTD_createDCtx() -> *mut ZSTD_DCtx;
155}
156unsafe extern "C" {
157    pub fn ZSTD_freeDCtx(dctx: *mut ZSTD_DCtx) -> usize;
158}
159unsafe extern "C" {
160    /// ZSTD_decompressDCtx() :
161    ///  Same as ZSTD_decompress(),
162    ///  requires an allocated ZSTD_DCtx.
163    ///  Compatible with sticky parameters (see below).
164    pub fn ZSTD_decompressDCtx(
165        dctx: *mut ZSTD_DCtx,
166        dst: *mut ::core::ffi::c_void,
167        dstCapacity: usize,
168        src: *const ::core::ffi::c_void,
169        srcSize: usize,
170    ) -> usize;
171}
172#[repr(u32)]
173///  Advanced compression API (Requires v1.4.0+)
174#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
175pub enum ZSTD_strategy {
176    ZSTD_fast = 1,
177    ZSTD_dfast = 2,
178    ZSTD_greedy = 3,
179    ZSTD_lazy = 4,
180    ZSTD_lazy2 = 5,
181    ZSTD_btlazy2 = 6,
182    ZSTD_btopt = 7,
183    ZSTD_btultra = 8,
184    ZSTD_btultra2 = 9,
185}
186#[repr(u32)]
187#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
188pub enum ZSTD_cParameter {
189    ZSTD_c_compressionLevel = 100,
190    ZSTD_c_windowLog = 101,
191    ZSTD_c_hashLog = 102,
192    ZSTD_c_chainLog = 103,
193    ZSTD_c_searchLog = 104,
194    ZSTD_c_minMatch = 105,
195    ZSTD_c_targetLength = 106,
196    ZSTD_c_strategy = 107,
197    ZSTD_c_targetCBlockSize = 130,
198    ZSTD_c_enableLongDistanceMatching = 160,
199    ZSTD_c_ldmHashLog = 161,
200    ZSTD_c_ldmMinMatch = 162,
201    ZSTD_c_ldmBucketSizeLog = 163,
202    ZSTD_c_ldmHashRateLog = 164,
203    ZSTD_c_contentSizeFlag = 200,
204    ZSTD_c_checksumFlag = 201,
205    ZSTD_c_dictIDFlag = 202,
206    ZSTD_c_nbWorkers = 400,
207    ZSTD_c_jobSize = 401,
208    ZSTD_c_overlapLog = 402,
209    ZSTD_c_experimentalParam1 = 500,
210    ZSTD_c_experimentalParam2 = 10,
211    ZSTD_c_experimentalParam3 = 1000,
212    ZSTD_c_experimentalParam4 = 1001,
213    ZSTD_c_experimentalParam5 = 1002,
214    ZSTD_c_experimentalParam7 = 1004,
215    ZSTD_c_experimentalParam8 = 1005,
216    ZSTD_c_experimentalParam9 = 1006,
217    ZSTD_c_experimentalParam10 = 1007,
218    ZSTD_c_experimentalParam11 = 1008,
219    ZSTD_c_experimentalParam12 = 1009,
220    ZSTD_c_experimentalParam13 = 1010,
221    ZSTD_c_experimentalParam14 = 1011,
222    ZSTD_c_experimentalParam15 = 1012,
223    ZSTD_c_experimentalParam16 = 1013,
224    ZSTD_c_experimentalParam17 = 1014,
225    ZSTD_c_experimentalParam18 = 1015,
226    ZSTD_c_experimentalParam19 = 1016,
227    ZSTD_c_experimentalParam20 = 1017,
228}
229#[repr(C)]
230#[derive(Debug, Copy, Clone)]
231pub struct ZSTD_bounds {
232    pub error: usize,
233    pub lowerBound: ::core::ffi::c_int,
234    pub upperBound: ::core::ffi::c_int,
235}
236unsafe extern "C" {
237    /// ZSTD_cParam_getBounds() :
238    ///  All parameters must belong to an interval with lower and upper bounds,
239    ///  otherwise they will either trigger an error or be automatically clamped.
240    /// @return : a structure, ZSTD_bounds, which contains
241    ///         - an error status field, which must be tested using ZSTD_isError()
242    ///         - lower and upper bounds, both inclusive
243    pub fn ZSTD_cParam_getBounds(cParam: ZSTD_cParameter) -> ZSTD_bounds;
244}
245unsafe extern "C" {
246    /// ZSTD_CCtx_setParameter() :
247    ///  Set one compression parameter, selected by enum ZSTD_cParameter.
248    ///  All parameters have valid bounds. Bounds can be queried using ZSTD_cParam_getBounds().
249    ///  Providing a value beyond bound will either clamp it, or trigger an error (depending on parameter).
250    ///  Setting a parameter is generally only possible during frame initialization (before starting compression).
251    ///  Exception : when using multi-threading mode (nbWorkers >= 1),
252    ///              the following parameters can be updated _during_ compression (within same frame):
253    ///              => compressionLevel, hashLog, chainLog, searchLog, minMatch, targetLength and strategy.
254    ///              new parameters will be active for next job only (after a flush()).
255    /// @return : an error code (which can be tested using ZSTD_isError()).
256    pub fn ZSTD_CCtx_setParameter(
257        cctx: *mut ZSTD_CCtx,
258        param: ZSTD_cParameter,
259        value: ::core::ffi::c_int,
260    ) -> usize;
261}
262unsafe extern "C" {
263    /// ZSTD_CCtx_setPledgedSrcSize() :
264    ///  Total input data size to be compressed as a single frame.
265    ///  Value will be written in frame header, unless if explicitly forbidden using ZSTD_c_contentSizeFlag.
266    ///  This value will also be controlled at end of frame, and trigger an error if not respected.
267    /// @result : 0, or an error code (which can be tested with ZSTD_isError()).
268    ///  Note 1 : pledgedSrcSize==0 actually means zero, aka an empty frame.
269    ///           In order to mean "unknown content size", pass constant ZSTD_CONTENTSIZE_UNKNOWN.
270    ///           ZSTD_CONTENTSIZE_UNKNOWN is default value for any new frame.
271    ///  Note 2 : pledgedSrcSize is only valid once, for the next frame.
272    ///           It's discarded at the end of the frame, and replaced by ZSTD_CONTENTSIZE_UNKNOWN.
273    ///  Note 3 : Whenever all input data is provided and consumed in a single round,
274    ///           for example with ZSTD_compress2(),
275    ///           or invoking immediately ZSTD_compressStream2(,,,ZSTD_e_end),
276    ///           this value is automatically overridden by srcSize instead.
277    pub fn ZSTD_CCtx_setPledgedSrcSize(
278        cctx: *mut ZSTD_CCtx,
279        pledgedSrcSize: ::core::ffi::c_ulonglong,
280    ) -> usize;
281}
282#[repr(u32)]
283#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
284pub enum ZSTD_ResetDirective {
285    ZSTD_reset_session_only = 1,
286    ZSTD_reset_parameters = 2,
287    ZSTD_reset_session_and_parameters = 3,
288}
289unsafe extern "C" {
290    /// ZSTD_CCtx_reset() :
291    ///  There are 2 different things that can be reset, independently or jointly :
292    ///  - The session : will stop compressing current frame, and make CCtx ready to start a new one.
293    ///                  Useful after an error, or to interrupt any ongoing compression.
294    ///                  Any internal data not yet flushed is cancelled.
295    ///                  Compression parameters and dictionary remain unchanged.
296    ///                  They will be used to compress next frame.
297    ///                  Resetting session never fails.
298    ///  - The parameters : changes all parameters back to "default".
299    ///                  This also removes any reference to any dictionary or external sequence producer.
300    ///                  Parameters can only be changed between 2 sessions (i.e. no compression is currently ongoing)
301    ///                  otherwise the reset fails, and function returns an error value (which can be tested using ZSTD_isError())
302    ///  - Both : similar to resetting the session, followed by resetting parameters.
303    pub fn ZSTD_CCtx_reset(cctx: *mut ZSTD_CCtx, reset: ZSTD_ResetDirective) -> usize;
304}
305unsafe extern "C" {
306    /// ZSTD_compress2() :
307    ///  Behave the same as ZSTD_compressCCtx(), but compression parameters are set using the advanced API.
308    ///  (note that this entry point doesn't even expose a compression level parameter).
309    ///  ZSTD_compress2() always starts a new frame.
310    ///  Should cctx hold data from a previously unfinished frame, everything about it is forgotten.
311    ///  - Compression parameters are pushed into CCtx before starting compression, using ZSTD_CCtx_set*()
312    ///  - The function is always blocking, returns when compression is completed.
313    ///  NOTE: Providing `dstCapacity >= ZSTD_compressBound(srcSize)` guarantees that zstd will have
314    ///        enough space to successfully compress the data, though it is possible it fails for other reasons.
315    /// @return : compressed size written into `dst` (<= `dstCapacity),
316    ///           or an error code if it fails (which can be tested using ZSTD_isError()).
317    pub fn ZSTD_compress2(
318        cctx: *mut ZSTD_CCtx,
319        dst: *mut ::core::ffi::c_void,
320        dstCapacity: usize,
321        src: *const ::core::ffi::c_void,
322        srcSize: usize,
323    ) -> usize;
324}
325#[repr(u32)]
326///  Advanced decompression API (Requires v1.4.0+)
327#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
328pub enum ZSTD_dParameter {
329    ZSTD_d_windowLogMax = 100,
330    ZSTD_d_experimentalParam1 = 1000,
331    ZSTD_d_experimentalParam2 = 1001,
332    ZSTD_d_experimentalParam3 = 1002,
333    ZSTD_d_experimentalParam4 = 1003,
334    ZSTD_d_experimentalParam5 = 1004,
335    ZSTD_d_experimentalParam6 = 1005,
336}
337unsafe extern "C" {
338    /// ZSTD_dParam_getBounds() :
339    ///  All parameters must belong to an interval with lower and upper bounds,
340    ///  otherwise they will either trigger an error or be automatically clamped.
341    /// @return : a structure, ZSTD_bounds, which contains
342    ///         - an error status field, which must be tested using ZSTD_isError()
343    ///         - both lower and upper bounds, inclusive
344    pub fn ZSTD_dParam_getBounds(dParam: ZSTD_dParameter) -> ZSTD_bounds;
345}
346unsafe extern "C" {
347    /// ZSTD_DCtx_setParameter() :
348    ///  Set one compression parameter, selected by enum ZSTD_dParameter.
349    ///  All parameters have valid bounds. Bounds can be queried using ZSTD_dParam_getBounds().
350    ///  Providing a value beyond bound will either clamp it, or trigger an error (depending on parameter).
351    ///  Setting a parameter is only possible during frame initialization (before starting decompression).
352    /// @return : 0, or an error code (which can be tested using ZSTD_isError()).
353    pub fn ZSTD_DCtx_setParameter(
354        dctx: *mut ZSTD_DCtx,
355        param: ZSTD_dParameter,
356        value: ::core::ffi::c_int,
357    ) -> usize;
358}
359unsafe extern "C" {
360    /// ZSTD_DCtx_reset() :
361    ///  Return a DCtx to clean state.
362    ///  Session and parameters can be reset jointly or separately.
363    ///  Parameters can only be reset when no active frame is being decompressed.
364    /// @return : 0, or an error code, which can be tested with ZSTD_isError()
365    pub fn ZSTD_DCtx_reset(dctx: *mut ZSTD_DCtx, reset: ZSTD_ResetDirective) -> usize;
366}
367///  Streaming
368#[repr(C)]
369#[derive(Debug, Copy, Clone)]
370pub struct ZSTD_inBuffer_s {
371    ///< start of input buffer
372    pub src: *const ::core::ffi::c_void,
373    ///< size of input buffer
374    pub size: usize,
375    ///< position where reading stopped. Will be updated. Necessarily 0 <= pos <= size
376    pub pos: usize,
377}
378///  Streaming
379pub type ZSTD_inBuffer = ZSTD_inBuffer_s;
380#[repr(C)]
381#[derive(Debug, Copy, Clone)]
382pub struct ZSTD_outBuffer_s {
383    ///< start of output buffer
384    pub dst: *mut ::core::ffi::c_void,
385    ///< size of output buffer
386    pub size: usize,
387    ///< position where writing stopped. Will be updated. Necessarily 0 <= pos <= size
388    pub pos: usize,
389}
390pub type ZSTD_outBuffer = ZSTD_outBuffer_s;
391pub type ZSTD_CStream = ZSTD_CCtx;
392unsafe extern "C" {
393    pub fn ZSTD_createCStream() -> *mut ZSTD_CStream;
394}
395unsafe extern "C" {
396    pub fn ZSTD_freeCStream(zcs: *mut ZSTD_CStream) -> usize;
397}
398#[repr(u32)]
399#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
400pub enum ZSTD_EndDirective {
401    ZSTD_e_continue = 0,
402    ZSTD_e_flush = 1,
403    ZSTD_e_end = 2,
404}
405unsafe extern "C" {
406    /// ZSTD_compressStream2() : Requires v1.4.0+
407    ///  Behaves about the same as ZSTD_compressStream, with additional control on end directive.
408    ///  - Compression parameters are pushed into CCtx before starting compression, using ZSTD_CCtx_set*()
409    ///  - Compression parameters cannot be changed once compression is started (save a list of exceptions in multi-threading mode)
410    ///  - output->pos must be <= dstCapacity, input->pos must be <= srcSize
411    ///  - output->pos and input->pos will be updated. They are guaranteed to remain below their respective limit.
412    ///  - endOp must be a valid directive
413    ///  - When nbWorkers==0 (default), function is blocking : it completes its job before returning to caller.
414    ///  - 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,
415    ///                                                  and then immediately returns, just indicating that there is some data remaining to be flushed.
416    ///                                                  The function nonetheless guarantees forward progress : it will return only after it reads or write at least 1+ byte.
417    ///  - 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.
418    ///  - @return provides a minimum amount of data remaining to be flushed from internal buffers
419    ///            or an error code, which can be tested using ZSTD_isError().
420    ///            if @return != 0, flush is not fully completed, there is still some data left within internal buffers.
421    ///            This is useful for ZSTD_e_flush, since in this case more flushes are necessary to empty all buffers.
422    ///            For ZSTD_e_end, @return == 0 when internal buffers are fully flushed and frame is completed.
423    ///  - after a ZSTD_e_end directive, if internal buffer is not fully flushed (@return != 0),
424    ///            only ZSTD_e_end or ZSTD_e_flush operations are allowed.
425    ///            Before starting a new compression job, or changing compression parameters,
426    ///            it is required to fully flush internal buffers.
427    ///  - note: if an operation ends with an error, it may leave @cctx in an undefined state.
428    ///          Therefore, it's UB to invoke ZSTD_compressStream2() of ZSTD_compressStream() on such a state.
429    ///          In order to be re-employed after an error, a state must be reset,
430    ///          which can be done explicitly (ZSTD_CCtx_reset()),
431    ///          or is sometimes implied by methods starting a new compression job (ZSTD_initCStream(), ZSTD_compressCCtx())
432    pub fn ZSTD_compressStream2(
433        cctx: *mut ZSTD_CCtx,
434        output: *mut ZSTD_outBuffer,
435        input: *mut ZSTD_inBuffer,
436        endOp: ZSTD_EndDirective,
437    ) -> usize;
438}
439unsafe extern "C" {
440    pub fn ZSTD_CStreamInSize() -> usize;
441}
442unsafe extern "C" {
443    pub fn ZSTD_CStreamOutSize() -> usize;
444}
445unsafe extern "C" {
446    /// Equivalent to:
447    ///
448    ///     ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only);
449    ///     ZSTD_CCtx_refCDict(zcs, NULL); // clear the dictionary (if any)
450    ///     ZSTD_CCtx_setParameter(zcs, ZSTD_c_compressionLevel, compressionLevel);
451    ///
452    /// Note that ZSTD_initCStream() clears any previously set dictionary. Use the new API
453    /// to compress with a dictionary.
454    pub fn ZSTD_initCStream(zcs: *mut ZSTD_CStream, compressionLevel: ::core::ffi::c_int) -> usize;
455}
456unsafe extern "C" {
457    /// Alternative for ZSTD_compressStream2(zcs, output, input, ZSTD_e_continue).
458    /// NOTE: The return value is different. ZSTD_compressStream() returns a hint for
459    /// the next read size (if non-zero and not an error). ZSTD_compressStream2()
460    /// returns the minimum nb of bytes left to flush (if non-zero and not an error).
461    pub fn ZSTD_compressStream(
462        zcs: *mut ZSTD_CStream,
463        output: *mut ZSTD_outBuffer,
464        input: *mut ZSTD_inBuffer,
465    ) -> usize;
466}
467unsafe extern "C" {
468    /// Equivalent to ZSTD_compressStream2(zcs, output, &emptyInput, ZSTD_e_flush).
469    pub fn ZSTD_flushStream(zcs: *mut ZSTD_CStream, output: *mut ZSTD_outBuffer) -> usize;
470}
471unsafe extern "C" {
472    /// Equivalent to ZSTD_compressStream2(zcs, output, &emptyInput, ZSTD_e_end).
473    pub fn ZSTD_endStream(zcs: *mut ZSTD_CStream, output: *mut ZSTD_outBuffer) -> usize;
474}
475pub type ZSTD_DStream = ZSTD_DCtx;
476unsafe extern "C" {
477    pub fn ZSTD_createDStream() -> *mut ZSTD_DStream;
478}
479unsafe extern "C" {
480    pub fn ZSTD_freeDStream(zds: *mut ZSTD_DStream) -> usize;
481}
482unsafe extern "C" {
483    /// ZSTD_initDStream() :
484    /// Initialize/reset DStream state for new decompression operation.
485    /// Call before new decompression operation using same DStream.
486    ///
487    /// Note : This function is redundant with the advanced API and equivalent to:
488    ///     ZSTD_DCtx_reset(zds, ZSTD_reset_session_only);
489    ///     ZSTD_DCtx_refDDict(zds, NULL);
490    pub fn ZSTD_initDStream(zds: *mut ZSTD_DStream) -> usize;
491}
492unsafe extern "C" {
493    /// ZSTD_decompressStream() :
494    /// Streaming decompression function.
495    /// Call repetitively to consume full input updating it as necessary.
496    /// Function will update both input and output `pos` fields exposing current state via these fields:
497    /// - `input.pos < input.size`, some input remaining and caller should provide remaining input
498    ///   on the next call.
499    /// - `output.pos < output.size`, decoder flushed internal output buffer.
500    /// - `output.pos == output.size`, unflushed data potentially present in the internal buffers,
501    ///   check ZSTD_decompressStream() @return value,
502    ///   if > 0, invoke it again to flush remaining data to output.
503    /// Note : with no additional input, amount of data flushed <= ZSTD_BLOCKSIZE_MAX.
504    ///
505    /// @return : 0 when a frame is completely decoded and fully flushed,
506    ///           or an error code, which can be tested using ZSTD_isError(),
507    ///           or any other value > 0, which means there is some decoding or flushing to do to complete current frame.
508    ///
509    /// Note: when an operation returns with an error code, the @zds state may be left in undefined state.
510    ///       It's UB to invoke `ZSTD_decompressStream()` on such a state.
511    ///       In order to re-use such a state, it must be first reset,
512    ///       which can be done explicitly (`ZSTD_DCtx_reset()`),
513    ///       or is implied for operations starting some new decompression job (`ZSTD_initDStream`, `ZSTD_decompressDCtx()`, `ZSTD_decompress_usingDict()`)
514    pub fn ZSTD_decompressStream(
515        zds: *mut ZSTD_DStream,
516        output: *mut ZSTD_outBuffer,
517        input: *mut ZSTD_inBuffer,
518    ) -> usize;
519}
520unsafe extern "C" {
521    pub fn ZSTD_DStreamInSize() -> usize;
522}
523unsafe extern "C" {
524    pub fn ZSTD_DStreamOutSize() -> usize;
525}
526unsafe extern "C" {
527    ///  Simple dictionary API
528    ////
529    ////*! ZSTD_compress_usingDict() :
530    ///  Compression at an explicit compression level using a Dictionary.
531    ///  A dictionary can be any arbitrary data segment (also called a prefix),
532    ///  or a buffer with specified information (see zdict.h).
533    ///  Note : This function loads the dictionary, resulting in significant startup delay.
534    ///         It's intended for a dictionary used only once.
535    ///  Note 2 : When `dict == NULL || dictSize < 8` no dictionary is used.
536    pub fn ZSTD_compress_usingDict(
537        ctx: *mut ZSTD_CCtx,
538        dst: *mut ::core::ffi::c_void,
539        dstCapacity: usize,
540        src: *const ::core::ffi::c_void,
541        srcSize: usize,
542        dict: *const ::core::ffi::c_void,
543        dictSize: usize,
544        compressionLevel: ::core::ffi::c_int,
545    ) -> usize;
546}
547unsafe extern "C" {
548    /// ZSTD_decompress_usingDict() :
549    ///  Decompression using a known Dictionary.
550    ///  Dictionary must be identical to the one used during compression.
551    ///  Note : This function loads the dictionary, resulting in significant startup delay.
552    ///         It's intended for a dictionary used only once.
553    ///  Note : When `dict == NULL || dictSize < 8` no dictionary is used.
554    pub fn ZSTD_decompress_usingDict(
555        dctx: *mut ZSTD_DCtx,
556        dst: *mut ::core::ffi::c_void,
557        dstCapacity: usize,
558        src: *const ::core::ffi::c_void,
559        srcSize: usize,
560        dict: *const ::core::ffi::c_void,
561        dictSize: usize,
562    ) -> usize;
563}
564#[repr(C)]
565#[derive(Debug)]
566pub struct ZSTD_CDict_s {
567    _unused: [u8; 0],
568}
569///  Bulk processing dictionary API
570pub type ZSTD_CDict = ZSTD_CDict_s;
571unsafe extern "C" {
572    /// ZSTD_createCDict() :
573    ///  When compressing multiple messages or blocks using the same dictionary,
574    ///  it's recommended to digest the dictionary only once, since it's a costly operation.
575    ///  ZSTD_createCDict() will create a state from digesting a dictionary.
576    ///  The resulting state can be used for future compression operations with very limited startup cost.
577    ///  ZSTD_CDict can be created once and shared by multiple threads concurrently, since its usage is read-only.
578    /// @dictBuffer can be released after ZSTD_CDict creation, because its content is copied within CDict.
579    ///  Note 1 : Consider experimental function `ZSTD_createCDict_byReference()` if you prefer to not duplicate @dictBuffer content.
580    ///  Note 2 : A ZSTD_CDict can be created from an empty @dictBuffer,
581    ///      in which case the only thing that it transports is the @compressionLevel.
582    ///      This can be useful in a pipeline featuring ZSTD_compress_usingCDict() exclusively,
583    ///      expecting a ZSTD_CDict parameter with any data, including those without a known dictionary.
584    pub fn ZSTD_createCDict(
585        dictBuffer: *const ::core::ffi::c_void,
586        dictSize: usize,
587        compressionLevel: ::core::ffi::c_int,
588    ) -> *mut ZSTD_CDict;
589}
590unsafe extern "C" {
591    /// ZSTD_freeCDict() :
592    ///  Function frees memory allocated by ZSTD_createCDict().
593    ///  If a NULL pointer is passed, no operation is performed.
594    pub fn ZSTD_freeCDict(CDict: *mut ZSTD_CDict) -> usize;
595}
596unsafe extern "C" {
597    /// ZSTD_compress_usingCDict() :
598    ///  Compression using a digested Dictionary.
599    ///  Recommended when same dictionary is used multiple times.
600    ///  Note : compression level is _decided at dictionary creation time_,
601    ///     and frame parameters are hardcoded (dictID=yes, contentSize=yes, checksum=no)
602    pub fn ZSTD_compress_usingCDict(
603        cctx: *mut ZSTD_CCtx,
604        dst: *mut ::core::ffi::c_void,
605        dstCapacity: usize,
606        src: *const ::core::ffi::c_void,
607        srcSize: usize,
608        cdict: *const ZSTD_CDict,
609    ) -> usize;
610}
611#[repr(C)]
612#[derive(Debug)]
613pub struct ZSTD_DDict_s {
614    _unused: [u8; 0],
615}
616pub type ZSTD_DDict = ZSTD_DDict_s;
617unsafe extern "C" {
618    /// ZSTD_createDDict() :
619    ///  Create a digested dictionary, ready to start decompression operation without startup delay.
620    ///  dictBuffer can be released after DDict creation, as its content is copied inside DDict.
621    pub fn ZSTD_createDDict(
622        dictBuffer: *const ::core::ffi::c_void,
623        dictSize: usize,
624    ) -> *mut ZSTD_DDict;
625}
626unsafe extern "C" {
627    /// ZSTD_freeDDict() :
628    ///  Function frees memory allocated with ZSTD_createDDict()
629    ///  If a NULL pointer is passed, no operation is performed.
630    pub fn ZSTD_freeDDict(ddict: *mut ZSTD_DDict) -> usize;
631}
632unsafe extern "C" {
633    /// ZSTD_decompress_usingDDict() :
634    ///  Decompression using a digested Dictionary.
635    ///  Recommended when same dictionary is used multiple times.
636    pub fn ZSTD_decompress_usingDDict(
637        dctx: *mut ZSTD_DCtx,
638        dst: *mut ::core::ffi::c_void,
639        dstCapacity: usize,
640        src: *const ::core::ffi::c_void,
641        srcSize: usize,
642        ddict: *const ZSTD_DDict,
643    ) -> usize;
644}
645unsafe extern "C" {
646    /// ZSTD_getDictID_fromDict() : Requires v1.4.0+
647    ///  Provides the dictID stored within dictionary.
648    ///  if @return == 0, the dictionary is not conformant with Zstandard specification.
649    ///  It can still be loaded, but as a content-only dictionary.
650    pub fn ZSTD_getDictID_fromDict(
651        dict: *const ::core::ffi::c_void,
652        dictSize: usize,
653    ) -> ::core::ffi::c_uint;
654}
655unsafe extern "C" {
656    /// ZSTD_getDictID_fromCDict() : Requires v1.5.0+
657    ///  Provides the dictID of the dictionary loaded into `cdict`.
658    ///  If @return == 0, the dictionary is not conformant to Zstandard specification, or empty.
659    ///  Non-conformant dictionaries can still be loaded, but as content-only dictionaries.
660    pub fn ZSTD_getDictID_fromCDict(cdict: *const ZSTD_CDict) -> ::core::ffi::c_uint;
661}
662unsafe extern "C" {
663    /// ZSTD_getDictID_fromDDict() : Requires v1.4.0+
664    ///  Provides the dictID of the dictionary loaded into `ddict`.
665    ///  If @return == 0, the dictionary is not conformant to Zstandard specification, or empty.
666    ///  Non-conformant dictionaries can still be loaded, but as content-only dictionaries.
667    pub fn ZSTD_getDictID_fromDDict(ddict: *const ZSTD_DDict) -> ::core::ffi::c_uint;
668}
669unsafe extern "C" {
670    /// ZSTD_getDictID_fromFrame() : Requires v1.4.0+
671    ///  Provides the dictID required to decompressed the frame stored within `src`.
672    ///  If @return == 0, the dictID could not be decoded.
673    ///  This could for one of the following reasons :
674    ///  - The frame does not require a dictionary to be decoded (most common case).
675    ///  - The frame was built with dictID intentionally removed. Whatever dictionary is necessary is a hidden piece of information.
676    ///    Note : this use case also happens when using a non-conformant dictionary.
677    ///  - `srcSize` is too small, and as a result, the frame header could not be decoded (only possible if `srcSize < ZSTD_FRAMEHEADERSIZE_MAX`).
678    ///  - This is not a Zstandard frame.
679    ///  When identifying the exact failure cause, it's possible to use ZSTD_getFrameHeader(), which will provide a more precise error code.
680    pub fn ZSTD_getDictID_fromFrame(
681        src: *const ::core::ffi::c_void,
682        srcSize: usize,
683    ) -> ::core::ffi::c_uint;
684}
685unsafe extern "C" {
686    /// ZSTD_CCtx_loadDictionary() : Requires v1.4.0+
687    ///  Create an internal CDict from `dict` buffer.
688    ///  Decompression will have to use same dictionary.
689    /// @result : 0, or an error code (which can be tested with ZSTD_isError()).
690    ///  Special: Loading a NULL (or 0-size) dictionary invalidates previous dictionary,
691    ///           meaning "return to no-dictionary mode".
692    ///  Note 1 : Dictionary is sticky, it will be used for all future compressed frames,
693    ///           until parameters are reset, a new dictionary is loaded, or the dictionary
694    ///           is explicitly invalidated by loading a NULL dictionary.
695    ///  Note 2 : Loading a dictionary involves building tables.
696    ///           It's also a CPU consuming operation, with non-negligible impact on latency.
697    ///           Tables are dependent on compression parameters, and for this reason,
698    ///           compression parameters can no longer be changed after loading a dictionary.
699    ///  Note 3 :`dict` content will be copied internally.
700    ///           Use experimental ZSTD_CCtx_loadDictionary_byReference() to reference content instead.
701    ///           In such a case, dictionary buffer must outlive its users.
702    ///  Note 4 : Use ZSTD_CCtx_loadDictionary_advanced()
703    ///           to precisely select how dictionary content must be interpreted.
704    ///  Note 5 : This method does not benefit from LDM (long distance mode).
705    ///           If you want to employ LDM on some large dictionary content,
706    ///           prefer employing ZSTD_CCtx_refPrefix() described below.
707    pub fn ZSTD_CCtx_loadDictionary(
708        cctx: *mut ZSTD_CCtx,
709        dict: *const ::core::ffi::c_void,
710        dictSize: usize,
711    ) -> usize;
712}
713unsafe extern "C" {
714    /// ZSTD_CCtx_refCDict() : Requires v1.4.0+
715    ///  Reference a prepared dictionary, to be used for all future compressed frames.
716    ///  Note that compression parameters are enforced from within CDict,
717    ///  and supersede any compression parameter previously set within CCtx.
718    ///  The parameters ignored are labelled as "superseded-by-cdict" in the ZSTD_cParameter enum docs.
719    ///  The ignored parameters will be used again if the CCtx is returned to no-dictionary mode.
720    ///  The dictionary will remain valid for future compressed frames using same CCtx.
721    /// @result : 0, or an error code (which can be tested with ZSTD_isError()).
722    ///  Special : Referencing a NULL CDict means "return to no-dictionary mode".
723    ///  Note 1 : Currently, only one dictionary can be managed.
724    ///           Referencing a new dictionary effectively "discards" any previous one.
725    ///  Note 2 : CDict is just referenced, its lifetime must outlive its usage within CCtx.
726    pub fn ZSTD_CCtx_refCDict(cctx: *mut ZSTD_CCtx, cdict: *const ZSTD_CDict) -> usize;
727}
728unsafe extern "C" {
729    /// ZSTD_CCtx_refPrefix() : Requires v1.4.0+
730    ///  Reference a prefix (single-usage dictionary) for next compressed frame.
731    ///  A prefix is **only used once**. Tables are discarded at end of frame (ZSTD_e_end).
732    ///  Decompression will need same prefix to properly regenerate data.
733    ///  Compressing with a prefix is similar in outcome as performing a diff and compressing it,
734    ///  but performs much faster, especially during decompression (compression speed is tunable with compression level).
735    ///  This method is compatible with LDM (long distance mode).
736    /// @result : 0, or an error code (which can be tested with ZSTD_isError()).
737    ///  Special: Adding any prefix (including NULL) invalidates any previous prefix or dictionary
738    ///  Note 1 : Prefix buffer is referenced. It **must** outlive compression.
739    ///           Its content must remain unmodified during compression.
740    ///  Note 2 : If the intention is to diff some large src data blob with some prior version of itself,
741    ///           ensure that the window size is large enough to contain the entire source.
742    ///           See ZSTD_c_windowLog.
743    ///  Note 3 : Referencing a prefix involves building tables, which are dependent on compression parameters.
744    ///           It's a CPU consuming operation, with non-negligible impact on latency.
745    ///           If there is a need to use the same prefix multiple times, consider loadDictionary instead.
746    ///  Note 4 : By default, the prefix is interpreted as raw content (ZSTD_dct_rawContent).
747    ///           Use experimental ZSTD_CCtx_refPrefix_advanced() to alter dictionary interpretation.
748    pub fn ZSTD_CCtx_refPrefix(
749        cctx: *mut ZSTD_CCtx,
750        prefix: *const ::core::ffi::c_void,
751        prefixSize: usize,
752    ) -> usize;
753}
754unsafe extern "C" {
755    /// ZSTD_DCtx_loadDictionary() : Requires v1.4.0+
756    ///  Create an internal DDict from dict buffer, to be used to decompress all future frames.
757    ///  The dictionary remains valid for all future frames, until explicitly invalidated, or
758    ///  a new dictionary is loaded.
759    /// @result : 0, or an error code (which can be tested with ZSTD_isError()).
760    ///  Special : Adding a NULL (or 0-size) dictionary invalidates any previous dictionary,
761    ///            meaning "return to no-dictionary mode".
762    ///  Note 1 : Loading a dictionary involves building tables,
763    ///           which has a non-negligible impact on CPU usage and latency.
764    ///           It's recommended to "load once, use many times", to amortize the cost
765    ///  Note 2 :`dict` content will be copied internally, so `dict` can be released after loading.
766    ///           Use ZSTD_DCtx_loadDictionary_byReference() to reference dictionary content instead.
767    ///  Note 3 : Use ZSTD_DCtx_loadDictionary_advanced() to take control of
768    ///           how dictionary content is loaded and interpreted.
769    pub fn ZSTD_DCtx_loadDictionary(
770        dctx: *mut ZSTD_DCtx,
771        dict: *const ::core::ffi::c_void,
772        dictSize: usize,
773    ) -> usize;
774}
775unsafe extern "C" {
776    /// ZSTD_DCtx_refDDict() : Requires v1.4.0+
777    ///  Reference a prepared dictionary, to be used to decompress next frames.
778    ///  The dictionary remains active for decompression of future frames using same DCtx.
779    ///
780    ///  If called with ZSTD_d_refMultipleDDicts enabled, repeated calls of this function
781    ///  will store the DDict references in a table, and the DDict used for decompression
782    ///  will be determined at decompression time, as per the dict ID in the frame.
783    ///  The memory for the table is allocated on the first call to refDDict, and can be
784    ///  freed with ZSTD_freeDCtx().
785    ///
786    ///  If called with ZSTD_d_refMultipleDDicts disabled (the default), only one dictionary
787    ///  will be managed, and referencing a dictionary effectively "discards" any previous one.
788    ///
789    /// @result : 0, or an error code (which can be tested with ZSTD_isError()).
790    ///  Special: referencing a NULL DDict means "return to no-dictionary mode".
791    ///  Note 2 : DDict is just referenced, its lifetime must outlive its usage from DCtx.
792    pub fn ZSTD_DCtx_refDDict(dctx: *mut ZSTD_DCtx, ddict: *const ZSTD_DDict) -> usize;
793}
794unsafe extern "C" {
795    /// ZSTD_DCtx_refPrefix() : Requires v1.4.0+
796    ///  Reference a prefix (single-usage dictionary) to decompress next frame.
797    ///  This is the reverse operation of ZSTD_CCtx_refPrefix(),
798    ///  and must use the same prefix as the one used during compression.
799    ///  Prefix is **only used once**. Reference is discarded at end of frame.
800    ///  End of frame is reached when ZSTD_decompressStream() returns 0.
801    /// @result : 0, or an error code (which can be tested with ZSTD_isError()).
802    ///  Note 1 : Adding any prefix (including NULL) invalidates any previously set prefix or dictionary
803    ///  Note 2 : Prefix buffer is referenced. It **must** outlive decompression.
804    ///           Prefix buffer must remain unmodified up to the end of frame,
805    ///           reached when ZSTD_decompressStream() returns 0.
806    ///  Note 3 : By default, the prefix is treated as raw content (ZSTD_dct_rawContent).
807    ///           Use ZSTD_CCtx_refPrefix_advanced() to alter dictMode (Experimental section)
808    ///  Note 4 : Referencing a raw content prefix has almost no cpu nor memory cost.
809    ///           A full dictionary is more costly, as it requires building tables.
810    pub fn ZSTD_DCtx_refPrefix(
811        dctx: *mut ZSTD_DCtx,
812        prefix: *const ::core::ffi::c_void,
813        prefixSize: usize,
814    ) -> usize;
815}
816unsafe extern "C" {
817    /// ZSTD_sizeof_*() : Requires v1.4.0+
818    ///  These functions give the _current_ memory usage of selected object.
819    ///  Note that object memory usage can evolve (increase or decrease) over time.
820    pub fn ZSTD_sizeof_CCtx(cctx: *const ZSTD_CCtx) -> usize;
821}
822unsafe extern "C" {
823    pub fn ZSTD_sizeof_DCtx(dctx: *const ZSTD_DCtx) -> usize;
824}
825unsafe extern "C" {
826    pub fn ZSTD_sizeof_CStream(zcs: *const ZSTD_CStream) -> usize;
827}
828unsafe extern "C" {
829    pub fn ZSTD_sizeof_DStream(zds: *const ZSTD_DStream) -> usize;
830}
831unsafe extern "C" {
832    pub fn ZSTD_sizeof_CDict(cdict: *const ZSTD_CDict) -> usize;
833}
834unsafe extern "C" {
835    pub fn ZSTD_sizeof_DDict(ddict: *const ZSTD_DDict) -> usize;
836}