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