1pub const ZSTD_VERSION_MAJOR: u32 = 1;
39pub const ZSTD_VERSION_MINOR: u32 = 5;
40pub const ZSTD_VERSION_RELEASE: u32 = 7;
41pub const ZSTD_VERSION_NUMBER: u32 = 10507;
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;
51#[repr(u32)]
52#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
53pub enum ZSTD_ErrorCode {
54 ZSTD_error_no_error = 0,
55 ZSTD_error_GENERIC = 1,
56 ZSTD_error_prefix_unknown = 10,
57 ZSTD_error_version_unsupported = 12,
58 ZSTD_error_frameParameter_unsupported = 14,
59 ZSTD_error_frameParameter_windowTooLarge = 16,
60 ZSTD_error_corruption_detected = 20,
61 ZSTD_error_checksum_wrong = 22,
62 ZSTD_error_literals_headerWrong = 24,
63 ZSTD_error_dictionary_corrupted = 30,
64 ZSTD_error_dictionary_wrong = 32,
65 ZSTD_error_dictionaryCreation_failed = 34,
66 ZSTD_error_parameter_unsupported = 40,
67 ZSTD_error_parameter_combination_unsupported = 41,
68 ZSTD_error_parameter_outOfBound = 42,
69 ZSTD_error_tableLog_tooLarge = 44,
70 ZSTD_error_maxSymbolValue_tooLarge = 46,
71 ZSTD_error_maxSymbolValue_tooSmall = 48,
72 ZSTD_error_cannotProduce_uncompressedBlock = 49,
73 ZSTD_error_stabilityCondition_notRespected = 50,
74 ZSTD_error_stage_wrong = 60,
75 ZSTD_error_init_missing = 62,
76 ZSTD_error_memory_allocation = 64,
77 ZSTD_error_workSpace_tooSmall = 66,
78 ZSTD_error_dstSize_tooSmall = 70,
79 ZSTD_error_srcSize_wrong = 72,
80 ZSTD_error_dstBuffer_null = 74,
81 ZSTD_error_noForwardProgress_destFull = 80,
82 ZSTD_error_noForwardProgress_inputEmpty = 82,
83 ZSTD_error_frameIndex_tooLarge = 100,
84 ZSTD_error_seekableIO = 102,
85 ZSTD_error_dstBuffer_wrong = 104,
86 ZSTD_error_srcBuffer_wrong = 105,
87 ZSTD_error_sequenceProducer_failed = 106,
88 ZSTD_error_externalSequences_invalid = 107,
89 ZSTD_error_maxCode = 120,
90}
91extern "C" {
92 pub fn ZSTD_getErrorString(
93 code: ZSTD_ErrorCode,
94 ) -> *const ::core::ffi::c_char;
95}
96extern "C" {
97 #[doc = " ZSTD_versionNumber() :\n Return runtime library version, the value is (MAJOR*100*100 + MINOR*100 + RELEASE)."]
98 pub fn ZSTD_versionNumber() -> ::core::ffi::c_uint;
99}
100extern "C" {
101 #[doc = " ZSTD_versionString() :\n Return runtime library version, like \"1.4.5\". Requires v1.3.0+."]
102 pub fn ZSTD_versionString() -> *const ::core::ffi::c_char;
103}
104extern "C" {
105 #[doc = " Simple Core 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())."]
106 pub fn ZSTD_compress(
107 dst: *mut ::core::ffi::c_void,
108 dstCapacity: usize,
109 src: *const ::core::ffi::c_void,
110 srcSize: usize,
111 compressionLevel: ::core::ffi::c_int,
112 ) -> usize;
113}
114extern "C" {
115 #[doc = " ZSTD_decompress() :\n `compressedSize` : must be the _exact_ size of some number of compressed and/or skippable frames.\n Multiple compressed frames can be decompressed at once with this method.\n The result will be the concatenation of all decompressed frames, back to back.\n `dstCapacity` is an upper bound of originalSize to regenerate.\n First frame's decompressed size can be extracted using ZSTD_getFrameContentSize().\n If maximum upper bound isn't known, prefer using 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())."]
116 pub fn ZSTD_decompress(
117 dst: *mut ::core::ffi::c_void,
118 dstCapacity: usize,
119 src: *const ::core::ffi::c_void,
120 compressedSize: usize,
121 ) -> usize;
122}
123extern "C" {
124 pub fn ZSTD_getFrameContentSize(
125 src: *const ::core::ffi::c_void,
126 srcSize: usize,
127 ) -> ::core::ffi::c_ulonglong;
128}
129extern "C" {
130 #[doc = " ZSTD_getDecompressedSize() (obsolete):\n 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."]
131 pub fn ZSTD_getDecompressedSize(
132 src: *const ::core::ffi::c_void,
133 srcSize: usize,
134 ) -> ::core::ffi::c_ulonglong;
135}
136extern "C" {
137 #[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\n Note 1: this method is called _find*() because it's not enough to read the header,\n it may have to scan through the frame's content, to reach its end.\n Note 2: this method also works with Skippable Frames. In which case,\n it returns the size of the complete skippable frame,\n which is always equal to its content size + 8 bytes for headers."]
138 pub fn ZSTD_findFrameCompressedSize(
139 src: *const ::core::ffi::c_void,
140 srcSize: usize,
141 ) -> usize;
142}
143extern "C" {
144 pub fn ZSTD_compressBound(srcSize: usize) -> usize;
145}
146extern "C" {
147 pub fn ZSTD_isError(result: usize) -> ::core::ffi::c_uint;
148}
149extern "C" {
150 pub fn ZSTD_getErrorCode(functionResult: usize) -> ZSTD_ErrorCode;
151}
152extern "C" {
153 pub fn ZSTD_getErrorName(result: usize) -> *const ::core::ffi::c_char;
154}
155extern "C" {
156 pub fn ZSTD_minCLevel() -> ::core::ffi::c_int;
157}
158extern "C" {
159 pub fn ZSTD_maxCLevel() -> ::core::ffi::c_int;
160}
161extern "C" {
162 pub fn ZSTD_defaultCLevel() -> ::core::ffi::c_int;
163}
164#[repr(C)]
165#[derive(Debug, Copy, Clone)]
166pub struct ZSTD_CCtx_s {
167 _unused: [u8; 0],
168}
169#[doc = " Explicit context"]
170pub type ZSTD_CCtx = ZSTD_CCtx_s;
171extern "C" {
172 pub fn ZSTD_createCCtx() -> *mut ZSTD_CCtx;
173}
174extern "C" {
175 pub fn ZSTD_freeCCtx(cctx: *mut ZSTD_CCtx) -> usize;
176}
177extern "C" {
178 #[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."]
179 pub fn ZSTD_compressCCtx(
180 cctx: *mut ZSTD_CCtx,
181 dst: *mut ::core::ffi::c_void,
182 dstCapacity: usize,
183 src: *const ::core::ffi::c_void,
184 srcSize: usize,
185 compressionLevel: ::core::ffi::c_int,
186 ) -> usize;
187}
188#[repr(C)]
189#[derive(Debug, Copy, Clone)]
190pub struct ZSTD_DCtx_s {
191 _unused: [u8; 0],
192}
193pub type ZSTD_DCtx = ZSTD_DCtx_s;
194extern "C" {
195 pub fn ZSTD_createDCtx() -> *mut ZSTD_DCtx;
196}
197extern "C" {
198 pub fn ZSTD_freeDCtx(dctx: *mut ZSTD_DCtx) -> usize;
199}
200extern "C" {
201 #[doc = " ZSTD_decompressDCtx() :\n Same as ZSTD_decompress(),\n requires an allocated ZSTD_DCtx.\n Compatible with sticky parameters (see below)."]
202 pub fn ZSTD_decompressDCtx(
203 dctx: *mut ZSTD_DCtx,
204 dst: *mut ::core::ffi::c_void,
205 dstCapacity: usize,
206 src: *const ::core::ffi::c_void,
207 srcSize: usize,
208 ) -> usize;
209}
210#[repr(u32)]
211#[doc = " Advanced compression API (Requires v1.4.0+)"]
212#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
213pub enum ZSTD_strategy {
214 ZSTD_fast = 1,
215 ZSTD_dfast = 2,
216 ZSTD_greedy = 3,
217 ZSTD_lazy = 4,
218 ZSTD_lazy2 = 5,
219 ZSTD_btlazy2 = 6,
220 ZSTD_btopt = 7,
221 ZSTD_btultra = 8,
222 ZSTD_btultra2 = 9,
223}
224#[repr(u32)]
225#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
226pub enum ZSTD_cParameter {
227 ZSTD_c_compressionLevel = 100,
228 ZSTD_c_windowLog = 101,
229 ZSTD_c_hashLog = 102,
230 ZSTD_c_chainLog = 103,
231 ZSTD_c_searchLog = 104,
232 ZSTD_c_minMatch = 105,
233 ZSTD_c_targetLength = 106,
234 ZSTD_c_strategy = 107,
235 ZSTD_c_targetCBlockSize = 130,
236 ZSTD_c_enableLongDistanceMatching = 160,
237 ZSTD_c_ldmHashLog = 161,
238 ZSTD_c_ldmMinMatch = 162,
239 ZSTD_c_ldmBucketSizeLog = 163,
240 ZSTD_c_ldmHashRateLog = 164,
241 ZSTD_c_contentSizeFlag = 200,
242 ZSTD_c_checksumFlag = 201,
243 ZSTD_c_dictIDFlag = 202,
244 ZSTD_c_nbWorkers = 400,
245 ZSTD_c_jobSize = 401,
246 ZSTD_c_overlapLog = 402,
247 ZSTD_c_experimentalParam1 = 500,
248 ZSTD_c_experimentalParam2 = 10,
249 ZSTD_c_experimentalParam3 = 1000,
250 ZSTD_c_experimentalParam4 = 1001,
251 ZSTD_c_experimentalParam5 = 1002,
252 ZSTD_c_experimentalParam7 = 1004,
253 ZSTD_c_experimentalParam8 = 1005,
254 ZSTD_c_experimentalParam9 = 1006,
255 ZSTD_c_experimentalParam10 = 1007,
256 ZSTD_c_experimentalParam11 = 1008,
257 ZSTD_c_experimentalParam12 = 1009,
258 ZSTD_c_experimentalParam13 = 1010,
259 ZSTD_c_experimentalParam14 = 1011,
260 ZSTD_c_experimentalParam15 = 1012,
261 ZSTD_c_experimentalParam16 = 1013,
262 ZSTD_c_experimentalParam17 = 1014,
263 ZSTD_c_experimentalParam18 = 1015,
264 ZSTD_c_experimentalParam19 = 1016,
265 ZSTD_c_experimentalParam20 = 1017,
266}
267#[repr(C)]
268#[derive(Debug, Copy, Clone)]
269pub struct ZSTD_bounds {
270 pub error: usize,
271 pub lowerBound: ::core::ffi::c_int,
272 pub upperBound: ::core::ffi::c_int,
273}
274extern "C" {
275 #[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"]
276 pub fn ZSTD_cParam_getBounds(cParam: ZSTD_cParameter) -> ZSTD_bounds;
277}
278extern "C" {
279 #[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())."]
280 pub fn ZSTD_CCtx_setParameter(
281 cctx: *mut ZSTD_CCtx,
282 param: ZSTD_cParameter,
283 value: ::core::ffi::c_int,
284 ) -> usize;
285}
286extern "C" {
287 #[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."]
288 pub fn ZSTD_CCtx_setPledgedSrcSize(
289 cctx: *mut ZSTD_CCtx,
290 pledgedSrcSize: ::core::ffi::c_ulonglong,
291 ) -> usize;
292}
293#[repr(u32)]
294#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
295pub enum ZSTD_ResetDirective {
296 ZSTD_reset_session_only = 1,
297 ZSTD_reset_parameters = 2,
298 ZSTD_reset_session_and_parameters = 3,
299}
300extern "C" {
301 #[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."]
302 pub fn ZSTD_CCtx_reset(
303 cctx: *mut ZSTD_CCtx,
304 reset: ZSTD_ResetDirective,
305 ) -> usize;
306}
307extern "C" {
308 #[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())."]
309 pub fn ZSTD_compress2(
310 cctx: *mut ZSTD_CCtx,
311 dst: *mut ::core::ffi::c_void,
312 dstCapacity: usize,
313 src: *const ::core::ffi::c_void,
314 srcSize: usize,
315 ) -> usize;
316}
317#[repr(u32)]
318#[doc = " Advanced decompression API (Requires v1.4.0+)"]
319#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
320pub enum ZSTD_dParameter {
321 ZSTD_d_windowLogMax = 100,
322 ZSTD_d_experimentalParam1 = 1000,
323 ZSTD_d_experimentalParam2 = 1001,
324 ZSTD_d_experimentalParam3 = 1002,
325 ZSTD_d_experimentalParam4 = 1003,
326 ZSTD_d_experimentalParam5 = 1004,
327 ZSTD_d_experimentalParam6 = 1005,
328}
329extern "C" {
330 #[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"]
331 pub fn ZSTD_dParam_getBounds(dParam: ZSTD_dParameter) -> ZSTD_bounds;
332}
333extern "C" {
334 #[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())."]
335 pub fn ZSTD_DCtx_setParameter(
336 dctx: *mut ZSTD_DCtx,
337 param: ZSTD_dParameter,
338 value: ::core::ffi::c_int,
339 ) -> usize;
340}
341extern "C" {
342 #[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()"]
343 pub fn ZSTD_DCtx_reset(
344 dctx: *mut ZSTD_DCtx,
345 reset: ZSTD_ResetDirective,
346 ) -> usize;
347}
348#[doc = " Streaming"]
349#[repr(C)]
350#[derive(Debug, Copy, Clone)]
351pub struct ZSTD_inBuffer_s {
352 #[doc = "< start of input buffer"]
353 pub src: *const ::core::ffi::c_void,
354 #[doc = "< size of input buffer"]
355 pub size: usize,
356 #[doc = "< position where reading stopped. Will be updated. Necessarily 0 <= pos <= size"]
357 pub pos: usize,
358}
359#[doc = " Streaming"]
360pub type ZSTD_inBuffer = ZSTD_inBuffer_s;
361#[repr(C)]
362#[derive(Debug, Copy, Clone)]
363pub struct ZSTD_outBuffer_s {
364 #[doc = "< start of output buffer"]
365 pub dst: *mut ::core::ffi::c_void,
366 #[doc = "< size of output buffer"]
367 pub size: usize,
368 #[doc = "< position where writing stopped. Will be updated. Necessarily 0 <= pos <= size"]
369 pub pos: usize,
370}
371pub type ZSTD_outBuffer = ZSTD_outBuffer_s;
372pub type ZSTD_CStream = ZSTD_CCtx;
373extern "C" {
374 pub fn ZSTD_createCStream() -> *mut ZSTD_CStream;
375}
376extern "C" {
377 pub fn ZSTD_freeCStream(zcs: *mut ZSTD_CStream) -> usize;
378}
379#[repr(u32)]
380#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
381pub enum ZSTD_EndDirective {
382 ZSTD_e_continue = 0,
383 ZSTD_e_flush = 1,
384 ZSTD_e_end = 2,
385}
386extern "C" {
387 #[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())"]
388 pub fn ZSTD_compressStream2(
389 cctx: *mut ZSTD_CCtx,
390 output: *mut ZSTD_outBuffer,
391 input: *mut ZSTD_inBuffer,
392 endOp: ZSTD_EndDirective,
393 ) -> usize;
394}
395extern "C" {
396 pub fn ZSTD_CStreamInSize() -> usize;
397}
398extern "C" {
399 pub fn ZSTD_CStreamOutSize() -> usize;
400}
401extern "C" {
402 #[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."]
403 pub fn ZSTD_initCStream(
404 zcs: *mut ZSTD_CStream,
405 compressionLevel: ::core::ffi::c_int,
406 ) -> usize;
407}
408extern "C" {
409 #[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)."]
410 pub fn ZSTD_compressStream(
411 zcs: *mut ZSTD_CStream,
412 output: *mut ZSTD_outBuffer,
413 input: *mut ZSTD_inBuffer,
414 ) -> usize;
415}
416extern "C" {
417 #[doc = " Equivalent to ZSTD_compressStream2(zcs, output, &emptyInput, ZSTD_e_flush)."]
418 pub fn ZSTD_flushStream(
419 zcs: *mut ZSTD_CStream,
420 output: *mut ZSTD_outBuffer,
421 ) -> usize;
422}
423extern "C" {
424 #[doc = " Equivalent to ZSTD_compressStream2(zcs, output, &emptyInput, ZSTD_e_end)."]
425 pub fn ZSTD_endStream(
426 zcs: *mut ZSTD_CStream,
427 output: *mut ZSTD_outBuffer,
428 ) -> usize;
429}
430pub type ZSTD_DStream = ZSTD_DCtx;
431extern "C" {
432 pub fn ZSTD_createDStream() -> *mut ZSTD_DStream;
433}
434extern "C" {
435 pub fn ZSTD_freeDStream(zds: *mut ZSTD_DStream) -> usize;
436}
437extern "C" {
438 #[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);"]
439 pub fn ZSTD_initDStream(zds: *mut ZSTD_DStream) -> usize;
440}
441extern "C" {
442 #[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 flushed internal output buffer.\n - `output.pos == output.size`, unflushed data potentially present in the internal buffers,\n check ZSTD_decompressStream() @return value,\n if > 0, invoke it 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()`)"]
443 pub fn ZSTD_decompressStream(
444 zds: *mut ZSTD_DStream,
445 output: *mut ZSTD_outBuffer,
446 input: *mut ZSTD_inBuffer,
447 ) -> usize;
448}
449extern "C" {
450 pub fn ZSTD_DStreamInSize() -> usize;
451}
452extern "C" {
453 pub fn ZSTD_DStreamOutSize() -> usize;
454}
455extern "C" {
456 #[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."]
457 pub fn ZSTD_compress_usingDict(
458 ctx: *mut ZSTD_CCtx,
459 dst: *mut ::core::ffi::c_void,
460 dstCapacity: usize,
461 src: *const ::core::ffi::c_void,
462 srcSize: usize,
463 dict: *const ::core::ffi::c_void,
464 dictSize: usize,
465 compressionLevel: ::core::ffi::c_int,
466 ) -> usize;
467}
468extern "C" {
469 #[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."]
470 pub fn ZSTD_decompress_usingDict(
471 dctx: *mut ZSTD_DCtx,
472 dst: *mut ::core::ffi::c_void,
473 dstCapacity: usize,
474 src: *const ::core::ffi::c_void,
475 srcSize: usize,
476 dict: *const ::core::ffi::c_void,
477 dictSize: usize,
478 ) -> usize;
479}
480#[repr(C)]
481#[derive(Debug, Copy, Clone)]
482pub struct ZSTD_CDict_s {
483 _unused: [u8; 0],
484}
485#[doc = " Bulk processing dictionary API"]
486pub type ZSTD_CDict = ZSTD_CDict_s;
487extern "C" {
488 #[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."]
489 pub fn ZSTD_createCDict(
490 dictBuffer: *const ::core::ffi::c_void,
491 dictSize: usize,
492 compressionLevel: ::core::ffi::c_int,
493 ) -> *mut ZSTD_CDict;
494}
495extern "C" {
496 #[doc = " ZSTD_freeCDict() :\n Function frees memory allocated by ZSTD_createCDict().\n If a NULL pointer is passed, no operation is performed."]
497 pub fn ZSTD_freeCDict(CDict: *mut ZSTD_CDict) -> usize;
498}
499extern "C" {
500 #[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)"]
501 pub fn ZSTD_compress_usingCDict(
502 cctx: *mut ZSTD_CCtx,
503 dst: *mut ::core::ffi::c_void,
504 dstCapacity: usize,
505 src: *const ::core::ffi::c_void,
506 srcSize: usize,
507 cdict: *const ZSTD_CDict,
508 ) -> usize;
509}
510#[repr(C)]
511#[derive(Debug, Copy, Clone)]
512pub struct ZSTD_DDict_s {
513 _unused: [u8; 0],
514}
515pub type ZSTD_DDict = ZSTD_DDict_s;
516extern "C" {
517 #[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."]
518 pub fn ZSTD_createDDict(
519 dictBuffer: *const ::core::ffi::c_void,
520 dictSize: usize,
521 ) -> *mut ZSTD_DDict;
522}
523extern "C" {
524 #[doc = " ZSTD_freeDDict() :\n Function frees memory allocated with ZSTD_createDDict()\n If a NULL pointer is passed, no operation is performed."]
525 pub fn ZSTD_freeDDict(ddict: *mut ZSTD_DDict) -> usize;
526}
527extern "C" {
528 #[doc = " ZSTD_decompress_usingDDict() :\n Decompression using a digested Dictionary.\n Recommended when same dictionary is used multiple times."]
529 pub fn ZSTD_decompress_usingDDict(
530 dctx: *mut ZSTD_DCtx,
531 dst: *mut ::core::ffi::c_void,
532 dstCapacity: usize,
533 src: *const ::core::ffi::c_void,
534 srcSize: usize,
535 ddict: *const ZSTD_DDict,
536 ) -> usize;
537}
538extern "C" {
539 #[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."]
540 pub fn ZSTD_getDictID_fromDict(
541 dict: *const ::core::ffi::c_void,
542 dictSize: usize,
543 ) -> ::core::ffi::c_uint;
544}
545extern "C" {
546 #[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."]
547 pub fn ZSTD_getDictID_fromCDict(
548 cdict: *const ZSTD_CDict,
549 ) -> ::core::ffi::c_uint;
550}
551extern "C" {
552 #[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."]
553 pub fn ZSTD_getDictID_fromDDict(
554 ddict: *const ZSTD_DDict,
555 ) -> ::core::ffi::c_uint;
556}
557extern "C" {
558 #[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."]
559 pub fn ZSTD_getDictID_fromFrame(
560 src: *const ::core::ffi::c_void,
561 srcSize: usize,
562 ) -> ::core::ffi::c_uint;
563}
564extern "C" {
565 #[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."]
566 pub fn ZSTD_CCtx_loadDictionary(
567 cctx: *mut ZSTD_CCtx,
568 dict: *const ::core::ffi::c_void,
569 dictSize: usize,
570 ) -> usize;
571}
572extern "C" {
573 #[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."]
574 pub fn ZSTD_CCtx_refCDict(
575 cctx: *mut ZSTD_CCtx,
576 cdict: *const ZSTD_CDict,
577 ) -> usize;
578}
579extern "C" {
580 #[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."]
581 pub fn ZSTD_CCtx_refPrefix(
582 cctx: *mut ZSTD_CCtx,
583 prefix: *const ::core::ffi::c_void,
584 prefixSize: usize,
585 ) -> usize;
586}
587extern "C" {
588 #[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."]
589 pub fn ZSTD_DCtx_loadDictionary(
590 dctx: *mut ZSTD_DCtx,
591 dict: *const ::core::ffi::c_void,
592 dictSize: usize,
593 ) -> usize;
594}
595extern "C" {
596 #[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."]
597 pub fn ZSTD_DCtx_refDDict(
598 dctx: *mut ZSTD_DCtx,
599 ddict: *const ZSTD_DDict,
600 ) -> usize;
601}
602extern "C" {
603 #[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."]
604 pub fn ZSTD_DCtx_refPrefix(
605 dctx: *mut ZSTD_DCtx,
606 prefix: *const ::core::ffi::c_void,
607 prefixSize: usize,
608 ) -> usize;
609}
610extern "C" {
611 #[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."]
612 pub fn ZSTD_sizeof_CCtx(cctx: *const ZSTD_CCtx) -> usize;
613}
614extern "C" {
615 pub fn ZSTD_sizeof_DCtx(dctx: *const ZSTD_DCtx) -> usize;
616}
617extern "C" {
618 pub fn ZSTD_sizeof_CStream(zcs: *const ZSTD_CStream) -> usize;
619}
620extern "C" {
621 pub fn ZSTD_sizeof_DStream(zds: *const ZSTD_DStream) -> usize;
622}
623extern "C" {
624 pub fn ZSTD_sizeof_CDict(cdict: *const ZSTD_CDict) -> usize;
625}
626extern "C" {
627 pub fn ZSTD_sizeof_DDict(ddict: *const ZSTD_DDict) -> usize;
628}