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