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