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 = 6;
41pub const ZSTD_VERSION_RELEASE: u32 = 0;
42pub const ZSTD_VERSION_NUMBER: u32 = 10600;
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 = " @brief Returns the decompressed content size stored in a ZSTD frame header.\n\n @since v1.3.0\n\n @param src Pointer to the beginning of a ZSTD encoded frame.\n @param srcSize Size of the buffer pointed to by @p src. It must be at least as large as the frame header.\n Any value greater than or equal to `ZSTD_frameHeaderSize_max` is sufficient.\n @return The decompressed size in bytes when the value is available in the frame header.\n @retval ZSTD_CONTENTSIZE_UNKNOWN The frame does not encode a decompressed size (typical for streaming).\n @retval ZSTD_CONTENTSIZE_ERROR An error occurred (e.g. invalid magic number, @p srcSize too small).\n\n @note The return value is not compatible with `ZSTD_isError()`.\n @note A return value of 0 denotes a valid but empty frame. Skippable frames also report 0.\n @note The decompressed size field is optional. When it is absent (the function returns @c ZSTD_CONTENTSIZE_UNKNOWN),\n the caller must rely on streaming decompression or an application-specific upper bound. `ZSTD_decompress()`\n only requires an upper bound, so applications may enforce their own block limits (for example 16 KB).\n @note The decompressed size is guaranteed to be present when compression was performed with single-pass APIs such as\n `ZSTD_compress()`, `ZSTD_compressCCtx()`, `ZSTD_compress_usingDict()`, or `ZSTD_compress_usingCDict()`.\n @note The decompressed size is a 64-bit value and may exceed the addressable space of the system. Use streaming\n decompression when the value is too large to materialize in contiguous memory.\n @warning When processing untrusted input, validate the returned size against the application's limits; attackers may\n forge an arbitrarily large value.\n @note 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}
145#[repr(u32)]
146#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
147pub enum ZSTD_FrameType_e {
148 ZSTD_frame = 0,
149 ZSTD_skippableFrame = 1,
150}
151#[repr(C)]
152#[derive(Debug, Copy, Clone)]
153pub struct ZSTD_FrameHeader {
154 #[doc = "< if == ZSTD_CONTENTSIZE_UNKNOWN, it means this field is not available. 0 means \"empty\""]
155 pub frameContentSize: ::core::ffi::c_ulonglong,
156 #[doc = "< can be very large, up to <= frameContentSize"]
157 pub windowSize: ::core::ffi::c_ulonglong,
158 pub blockSizeMax: ::core::ffi::c_uint,
159 #[doc = "< if == ZSTD_skippableFrame, frameContentSize is the size of skippable content"]
160 pub frameType: ZSTD_FrameType_e,
161 pub headerSize: ::core::ffi::c_uint,
162 #[doc = "< for ZSTD_skippableFrame, contains the skippable magic variant [0-15]"]
163 pub dictID: ::core::ffi::c_uint,
164 pub checksumFlag: ::core::ffi::c_uint,
165 pub _reserved1: ::core::ffi::c_uint,
166 pub _reserved2: ::core::ffi::c_uint,
167}
168extern "C" {
169 #[doc = " ZSTD_getFrameHeader() : Requires v1.6.0+\n decode Frame Header into `zfhPtr`, or requires larger `srcSize`.\n @return : 0 => header is complete, `zfhPtr` is correctly filled,\n >0 => `srcSize` is too small, @return value is the wanted `srcSize` amount, `zfhPtr` is not filled,\n or an error code, which can be tested using ZSTD_isError()"]
170 pub fn ZSTD_getFrameHeader(
171 zfhPtr: *mut ZSTD_FrameHeader,
172 src: *const ::core::ffi::c_void,
173 srcSize: usize,
174 ) -> usize;
175}
176extern "C" {
177 pub fn ZSTD_compressBound(srcSize: usize) -> usize;
178}
179extern "C" {
180 pub fn ZSTD_isError(result: usize) -> ::core::ffi::c_uint;
181}
182extern "C" {
183 pub fn ZSTD_getErrorCode(functionResult: usize) -> ZSTD_ErrorCode;
184}
185extern "C" {
186 pub fn ZSTD_getErrorName(result: usize) -> *const ::core::ffi::c_char;
187}
188extern "C" {
189 pub fn ZSTD_minCLevel() -> ::core::ffi::c_int;
190}
191extern "C" {
192 pub fn ZSTD_maxCLevel() -> ::core::ffi::c_int;
193}
194extern "C" {
195 pub fn ZSTD_defaultCLevel() -> ::core::ffi::c_int;
196}
197#[repr(C)]
198#[derive(Debug, Copy, Clone)]
199pub struct ZSTD_CCtx_s {
200 _unused: [u8; 0],
201}
202#[doc = " Explicit context"]
203pub type ZSTD_CCtx = ZSTD_CCtx_s;
204extern "C" {
205 pub fn ZSTD_createCCtx() -> *mut ZSTD_CCtx;
206}
207extern "C" {
208 pub fn ZSTD_freeCCtx(cctx: *mut ZSTD_CCtx) -> usize;
209}
210extern "C" {
211 #[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."]
212 pub fn ZSTD_compressCCtx(
213 cctx: *mut ZSTD_CCtx,
214 dst: *mut ::core::ffi::c_void,
215 dstCapacity: usize,
216 src: *const ::core::ffi::c_void,
217 srcSize: usize,
218 compressionLevel: ::core::ffi::c_int,
219 ) -> usize;
220}
221#[repr(C)]
222#[derive(Debug, Copy, Clone)]
223pub struct ZSTD_DCtx_s {
224 _unused: [u8; 0],
225}
226pub type ZSTD_DCtx = ZSTD_DCtx_s;
227extern "C" {
228 pub fn ZSTD_createDCtx() -> *mut ZSTD_DCtx;
229}
230extern "C" {
231 pub fn ZSTD_freeDCtx(dctx: *mut ZSTD_DCtx) -> usize;
232}
233extern "C" {
234 #[doc = " ZSTD_decompressDCtx() :\n Same as ZSTD_decompress(),\n requires an allocated ZSTD_DCtx.\n Compatible with sticky parameters (see below).\n The streaming session of @dctx is reset first, as with\n ZSTD_DCtx_reset(dctx, ZSTD_reset_session_only).\n See ZSTD_DCtx_refPrefix() for the effect on a referenced prefix."]
235 pub fn ZSTD_decompressDCtx(
236 dctx: *mut ZSTD_DCtx,
237 dst: *mut ::core::ffi::c_void,
238 dstCapacity: usize,
239 src: *const ::core::ffi::c_void,
240 srcSize: usize,
241 ) -> usize;
242}
243#[repr(u32)]
244#[doc = " Advanced compression API (Requires v1.4.0+)"]
245#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
246pub enum ZSTD_strategy {
247 ZSTD_fast = 1,
248 ZSTD_dfast = 2,
249 ZSTD_greedy = 3,
250 ZSTD_lazy = 4,
251 ZSTD_lazy2 = 5,
252 ZSTD_btlazy2 = 6,
253 ZSTD_btopt = 7,
254 ZSTD_btultra = 8,
255 ZSTD_btultra2 = 9,
256}
257#[repr(u32)]
258#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
259pub enum ZSTD_cParameter {
260 ZSTD_c_compressionLevel = 100,
261 ZSTD_c_windowLog = 101,
262 ZSTD_c_hashLog = 102,
263 ZSTD_c_chainLog = 103,
264 ZSTD_c_searchLog = 104,
265 ZSTD_c_minMatch = 105,
266 ZSTD_c_targetLength = 106,
267 ZSTD_c_strategy = 107,
268 ZSTD_c_targetCBlockSize = 130,
269 ZSTD_c_enableLongDistanceMatching = 160,
270 ZSTD_c_ldmHashLog = 161,
271 ZSTD_c_ldmMinMatch = 162,
272 ZSTD_c_ldmBucketSizeLog = 163,
273 ZSTD_c_ldmHashRateLog = 164,
274 ZSTD_c_contentSizeFlag = 200,
275 ZSTD_c_checksumFlag = 201,
276 ZSTD_c_dictIDFlag = 202,
277 ZSTD_c_nbWorkers = 400,
278 ZSTD_c_jobSize = 401,
279 ZSTD_c_overlapLog = 402,
280 ZSTD_c_experimentalParam1 = 500,
281 ZSTD_c_experimentalParam2 = 10,
282 ZSTD_c_experimentalParam3 = 1000,
283 ZSTD_c_experimentalParam4 = 1001,
284 ZSTD_c_experimentalParam5 = 1002,
285 ZSTD_c_experimentalParam7 = 1004,
286 ZSTD_c_experimentalParam8 = 1005,
287 ZSTD_c_experimentalParam9 = 1006,
288 ZSTD_c_experimentalParam10 = 1007,
289 ZSTD_c_experimentalParam11 = 1008,
290 ZSTD_c_experimentalParam12 = 1009,
291 ZSTD_c_experimentalParam13 = 1010,
292 ZSTD_c_experimentalParam14 = 1011,
293 ZSTD_c_experimentalParam15 = 1012,
294 ZSTD_c_experimentalParam16 = 1013,
295 ZSTD_c_experimentalParam17 = 1014,
296 ZSTD_c_experimentalParam18 = 1015,
297 ZSTD_c_experimentalParam19 = 1016,
298 ZSTD_c_experimentalParam20 = 1017,
299}
300#[repr(C)]
301#[derive(Debug, Copy, Clone)]
302pub struct ZSTD_bounds {
303 pub error: usize,
304 pub lowerBound: ::core::ffi::c_int,
305 pub upperBound: ::core::ffi::c_int,
306}
307extern "C" {
308 #[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"]
309 pub fn ZSTD_cParam_getBounds(cParam: ZSTD_cParameter) -> ZSTD_bounds;
310}
311extern "C" {
312 #[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())."]
313 pub fn ZSTD_CCtx_setParameter(
314 cctx: *mut ZSTD_CCtx,
315 param: ZSTD_cParameter,
316 value: ::core::ffi::c_int,
317 ) -> usize;
318}
319extern "C" {
320 #[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."]
321 pub fn ZSTD_CCtx_setPledgedSrcSize(
322 cctx: *mut ZSTD_CCtx,
323 pledgedSrcSize: ::core::ffi::c_ulonglong,
324 ) -> usize;
325}
326#[repr(u32)]
327#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
328pub enum ZSTD_ResetDirective {
329 ZSTD_reset_session_only = 1,
330 ZSTD_reset_parameters = 2,
331 ZSTD_reset_session_and_parameters = 3,
332}
333extern "C" {
334 #[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 With nbWorkers >= 1, it waits for the jobs already started to complete.\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."]
335 pub fn ZSTD_CCtx_reset(
336 cctx: *mut ZSTD_CCtx,
337 reset: ZSTD_ResetDirective,
338 ) -> usize;
339}
340extern "C" {
341 #[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())."]
342 pub fn ZSTD_compress2(
343 cctx: *mut ZSTD_CCtx,
344 dst: *mut ::core::ffi::c_void,
345 dstCapacity: usize,
346 src: *const ::core::ffi::c_void,
347 srcSize: usize,
348 ) -> usize;
349}
350#[repr(u32)]
351#[doc = " Advanced decompression API (Requires v1.4.0+)"]
352#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
353pub enum ZSTD_dParameter {
354 ZSTD_d_windowLogMax = 100,
355 ZSTD_d_experimentalParam1 = 1000,
356 ZSTD_d_experimentalParam2 = 1001,
357 ZSTD_d_experimentalParam3 = 1002,
358 ZSTD_d_experimentalParam4 = 1003,
359 ZSTD_d_experimentalParam5 = 1004,
360 ZSTD_d_experimentalParam6 = 1005,
361}
362extern "C" {
363 #[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"]
364 pub fn ZSTD_dParam_getBounds(dParam: ZSTD_dParameter) -> ZSTD_bounds;
365}
366extern "C" {
367 #[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())."]
368 pub fn ZSTD_DCtx_setParameter(
369 dctx: *mut ZSTD_DCtx,
370 param: ZSTD_dParameter,
371 value: ::core::ffi::c_int,
372 ) -> usize;
373}
374extern "C" {
375 #[doc = " ZSTD_DCtx_reset() :\n Return a DCtx to clean state.\n Session and parameters can be reset jointly or separately.\n ZSTD_reset_parameters can only be used when no frame is being decompressed;\n otherwise it returns ZSTD_error_stage_wrong without resetting the parameters.\n ZSTD_reset_session_and_parameters also abandons any active frame.\n A successful parameter reset discards any referenced prefix or dictionary.\n See ZSTD_DCtx_refPrefix() for the effect of a session-only reset on a prefix.\n @return : 0, or an error code, which can be tested with ZSTD_isError()"]
376 pub fn ZSTD_DCtx_reset(
377 dctx: *mut ZSTD_DCtx,
378 reset: ZSTD_ResetDirective,
379 ) -> usize;
380}
381#[doc = " Streaming"]
382#[repr(C)]
383#[derive(Debug, Copy, Clone)]
384pub struct ZSTD_inBuffer_s {
385 #[doc = "< start of input buffer"]
386 pub src: *const ::core::ffi::c_void,
387 #[doc = "< size of input buffer"]
388 pub size: usize,
389 #[doc = "< position where reading stopped. Will be updated. Necessarily 0 <= pos <= size"]
390 pub pos: usize,
391}
392#[doc = " Streaming"]
393pub type ZSTD_inBuffer = ZSTD_inBuffer_s;
394#[repr(C)]
395#[derive(Debug, Copy, Clone)]
396pub struct ZSTD_outBuffer_s {
397 #[doc = "< start of output buffer"]
398 pub dst: *mut ::core::ffi::c_void,
399 #[doc = "< size of output buffer"]
400 pub size: usize,
401 #[doc = "< position where writing stopped. Will be updated. Necessarily 0 <= pos <= size"]
402 pub pos: usize,
403}
404pub type ZSTD_outBuffer = ZSTD_outBuffer_s;
405pub type ZSTD_CStream = ZSTD_CCtx;
406extern "C" {
407 pub fn ZSTD_createCStream() -> *mut ZSTD_CStream;
408}
409extern "C" {
410 pub fn ZSTD_freeCStream(zcs: *mut ZSTD_CStream) -> usize;
411}
412#[repr(u32)]
413#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
414pub enum ZSTD_EndDirective {
415 ZSTD_e_continue = 0,
416 ZSTD_e_flush = 1,
417 ZSTD_e_end = 2,
418}
419extern "C" {
420 #[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())"]
421 pub fn ZSTD_compressStream2(
422 cctx: *mut ZSTD_CCtx,
423 output: *mut ZSTD_outBuffer,
424 input: *mut ZSTD_inBuffer,
425 endOp: ZSTD_EndDirective,
426 ) -> usize;
427}
428extern "C" {
429 pub fn ZSTD_CStreamInSize() -> usize;
430}
431extern "C" {
432 pub fn ZSTD_CStreamOutSize() -> usize;
433}
434extern "C" {
435 #[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."]
436 pub fn ZSTD_initCStream(
437 zcs: *mut ZSTD_CStream,
438 compressionLevel: ::core::ffi::c_int,
439 ) -> usize;
440}
441extern "C" {
442 #[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)."]
443 pub fn ZSTD_compressStream(
444 zcs: *mut ZSTD_CStream,
445 output: *mut ZSTD_outBuffer,
446 input: *mut ZSTD_inBuffer,
447 ) -> usize;
448}
449extern "C" {
450 #[doc = " Equivalent to ZSTD_compressStream2(zcs, output, &emptyInput, ZSTD_e_flush)."]
451 pub fn ZSTD_flushStream(
452 zcs: *mut ZSTD_CStream,
453 output: *mut ZSTD_outBuffer,
454 ) -> usize;
455}
456extern "C" {
457 #[doc = " Equivalent to ZSTD_compressStream2(zcs, output, &emptyInput, ZSTD_e_end)."]
458 pub fn ZSTD_endStream(
459 zcs: *mut ZSTD_CStream,
460 output: *mut ZSTD_outBuffer,
461 ) -> usize;
462}
463pub type ZSTD_DStream = ZSTD_DCtx;
464extern "C" {
465 pub fn ZSTD_createDStream() -> *mut ZSTD_DStream;
466}
467extern "C" {
468 pub fn ZSTD_freeDStream(zds: *mut ZSTD_DStream) -> usize;
469}
470extern "C" {
471 #[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);"]
472 pub fn ZSTD_initDStream(zds: *mut ZSTD_DStream) -> usize;
473}
474extern "C" {
475 #[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(zds, ZSTD_reset_session_only)`),\n or is implied for operations starting some new decompression job\n (`ZSTD_initDStream()`, `ZSTD_decompressDCtx()`, `ZSTD_decompress_usingDict()`, `ZSTD_decompress_usingDDict()`).\n The single-shot functions also leave the session clean:\n streaming can start a new frame afterwards without an explicit reset."]
476 pub fn ZSTD_decompressStream(
477 zds: *mut ZSTD_DStream,
478 output: *mut ZSTD_outBuffer,
479 input: *mut ZSTD_inBuffer,
480 ) -> usize;
481}
482extern "C" {
483 pub fn ZSTD_DStreamInSize() -> usize;
484}
485extern "C" {
486 pub fn ZSTD_DStreamOutSize() -> usize;
487}
488extern "C" {
489 #[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."]
490 pub fn ZSTD_compress_usingDict(
491 ctx: *mut ZSTD_CCtx,
492 dst: *mut ::core::ffi::c_void,
493 dstCapacity: usize,
494 src: *const ::core::ffi::c_void,
495 srcSize: usize,
496 dict: *const ::core::ffi::c_void,
497 dictSize: usize,
498 compressionLevel: ::core::ffi::c_int,
499 ) -> usize;
500}
501extern "C" {
502 #[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.\n Note : The streaming session of @dctx is reset first, as with\n ZSTD_DCtx_reset(dctx, ZSTD_reset_session_only)."]
503 pub fn ZSTD_decompress_usingDict(
504 dctx: *mut ZSTD_DCtx,
505 dst: *mut ::core::ffi::c_void,
506 dstCapacity: usize,
507 src: *const ::core::ffi::c_void,
508 srcSize: usize,
509 dict: *const ::core::ffi::c_void,
510 dictSize: usize,
511 ) -> usize;
512}
513#[repr(C)]
514#[derive(Debug, Copy, Clone)]
515pub struct ZSTD_CDict_s {
516 _unused: [u8; 0],
517}
518#[doc = " Bulk processing dictionary API"]
519pub type ZSTD_CDict = ZSTD_CDict_s;
520extern "C" {
521 #[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."]
522 pub fn ZSTD_createCDict(
523 dictBuffer: *const ::core::ffi::c_void,
524 dictSize: usize,
525 compressionLevel: ::core::ffi::c_int,
526 ) -> *mut ZSTD_CDict;
527}
528extern "C" {
529 #[doc = " ZSTD_freeCDict() :\n Function frees memory allocated by ZSTD_createCDict().\n If a NULL pointer is passed, no operation is performed."]
530 pub fn ZSTD_freeCDict(CDict: *mut ZSTD_CDict) -> usize;
531}
532extern "C" {
533 #[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)"]
534 pub fn ZSTD_compress_usingCDict(
535 cctx: *mut ZSTD_CCtx,
536 dst: *mut ::core::ffi::c_void,
537 dstCapacity: usize,
538 src: *const ::core::ffi::c_void,
539 srcSize: usize,
540 cdict: *const ZSTD_CDict,
541 ) -> usize;
542}
543#[repr(C)]
544#[derive(Debug, Copy, Clone)]
545pub struct ZSTD_DDict_s {
546 _unused: [u8; 0],
547}
548pub type ZSTD_DDict = ZSTD_DDict_s;
549extern "C" {
550 #[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."]
551 pub fn ZSTD_createDDict(
552 dictBuffer: *const ::core::ffi::c_void,
553 dictSize: usize,
554 ) -> *mut ZSTD_DDict;
555}
556extern "C" {
557 #[doc = " ZSTD_createDDict_byReference() : Requires v1.6.0+\n Create a digested dictionary, ready to start decompression operation without startup delay.\n Dictionary content is referenced, and therefore stays in dictBuffer.\n It is important that dictBuffer outlives DDict,\n it must remain read accessible throughout the lifetime of DDict"]
558 pub fn ZSTD_createDDict_byReference(
559 dictBuffer: *const ::core::ffi::c_void,
560 dictSize: usize,
561 ) -> *mut ZSTD_DDict;
562}
563extern "C" {
564 #[doc = " ZSTD_freeDDict() :\n Function frees memory allocated with ZSTD_createDDict()\n If a NULL pointer is passed, no operation is performed."]
565 pub fn ZSTD_freeDDict(ddict: *mut ZSTD_DDict) -> usize;
566}
567extern "C" {
568 #[doc = " ZSTD_decompress_usingDDict() :\n Decompression using a digested Dictionary.\n Recommended when same dictionary is used multiple times.\n Uses the supplied DDict, regardless of dictionaries referenced in dctx.\n The streaming session of @dctx is reset first, as with\n ZSTD_DCtx_reset(dctx, ZSTD_reset_session_only)."]
569 pub fn ZSTD_decompress_usingDDict(
570 dctx: *mut ZSTD_DCtx,
571 dst: *mut ::core::ffi::c_void,
572 dstCapacity: usize,
573 src: *const ::core::ffi::c_void,
574 srcSize: usize,
575 ddict: *const ZSTD_DDict,
576 ) -> usize;
577}
578extern "C" {
579 #[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."]
580 pub fn ZSTD_getDictID_fromDict(
581 dict: *const ::core::ffi::c_void,
582 dictSize: usize,
583 ) -> ::core::ffi::c_uint;
584}
585extern "C" {
586 #[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."]
587 pub fn ZSTD_getDictID_fromCDict(
588 cdict: *const ZSTD_CDict,
589 ) -> ::core::ffi::c_uint;
590}
591extern "C" {
592 #[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."]
593 pub fn ZSTD_getDictID_fromDDict(
594 ddict: *const ZSTD_DDict,
595 ) -> ::core::ffi::c_uint;
596}
597extern "C" {
598 #[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."]
599 pub fn ZSTD_getDictID_fromFrame(
600 src: *const ::core::ffi::c_void,
601 srcSize: usize,
602 ) -> ::core::ffi::c_uint;
603}
604extern "C" {
605 #[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."]
606 pub fn ZSTD_CCtx_loadDictionary(
607 cctx: *mut ZSTD_CCtx,
608 dict: *const ::core::ffi::c_void,
609 dictSize: usize,
610 ) -> usize;
611}
612#[repr(u32)]
613#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
614pub enum ZSTD_dictContentType_e {
615 #[doc = "< dictionary is \"full\" when starting with ZSTD_MAGIC_DICTIONARY, otherwise it is \"rawContent\""]
616 ZSTD_dct_auto = 0,
617 #[doc = "< ensures dictionary is always loaded as rawContent, even if it starts with ZSTD_MAGIC_DICTIONARY"]
618 ZSTD_dct_rawContent = 1,
619 #[doc = "< refuses to load a dictionary if it does not respect Zstandard's specification, starting with ZSTD_MAGIC_DICTIONARY"]
620 ZSTD_dct_fullDict = 2,
621}
622#[repr(u32)]
623#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
624pub enum ZSTD_dictLoadMethod_e {
625 #[doc = "< Copy dictionary content internally"]
626 ZSTD_dlm_byCopy = 0,
627 #[doc = "< Reference dictionary content -- the dictionary buffer must outlive its users."]
628 ZSTD_dlm_byRef = 1,
629}
630extern "C" {
631 #[doc = " ZSTD_CCtx_loadDictionary_advanced() : Requires v1.6.0+\n Same as ZSTD_CCtx_loadDictionary(), but gives finer control over\n how to load the dictionary (by copy ? by reference ?)\n and how to interpret it (automatic ? force raw mode ? full mode only ?)"]
632 pub fn ZSTD_CCtx_loadDictionary_advanced(
633 cctx: *mut ZSTD_CCtx,
634 dict: *const ::core::ffi::c_void,
635 dictSize: usize,
636 dictLoadMethod: ZSTD_dictLoadMethod_e,
637 dictContentType: ZSTD_dictContentType_e,
638 ) -> usize;
639}
640extern "C" {
641 #[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."]
642 pub fn ZSTD_CCtx_refCDict(
643 cctx: *mut ZSTD_CCtx,
644 cdict: *const ZSTD_CDict,
645 ) -> usize;
646}
647extern "C" {
648 #[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."]
649 pub fn ZSTD_CCtx_refPrefix(
650 cctx: *mut ZSTD_CCtx,
651 prefix: *const ::core::ffi::c_void,
652 prefixSize: usize,
653 ) -> usize;
654}
655extern "C" {
656 #[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 Loading any dictionary also discards the multiple-DDict reference table,\n without disabling ZSTD_d_refMultipleDDicts.\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."]
657 pub fn ZSTD_DCtx_loadDictionary(
658 dctx: *mut ZSTD_DCtx,
659 dict: *const ::core::ffi::c_void,
660 dictSize: usize,
661 ) -> usize;
662}
663extern "C" {
664 #[doc = " ZSTD_DCtx_loadDictionary_advanced() : Requires v1.6.0+\n Same as ZSTD_DCtx_loadDictionary(),\n but gives direct control over\n how to load the dictionary (by copy ? by reference ?)\n and how to interpret it (automatic ? force raw mode ? full mode only ?)."]
665 pub fn ZSTD_DCtx_loadDictionary_advanced(
666 dctx: *mut ZSTD_DCtx,
667 dict: *const ::core::ffi::c_void,
668 dictSize: usize,
669 dictLoadMethod: ZSTD_dictLoadMethod_e,
670 dictContentType: ZSTD_dictContentType_e,
671 ) -> usize;
672}
673extern "C" {
674 #[doc = " ZSTD_DCtx_refDDict() : Requires v1.4.0+\n Reference a prepared dictionary, to be used to decompress next frames.\n In single-DDict mode, the dictionary remains active for decompression of\n future frames using the 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.\n The table is freed by ZSTD_DCtx_refDDict(dctx, NULL), by ZSTD_DCtx_reset()\n with ZSTD_reset_parameters or ZSTD_reset_session_and_parameters, by any\n ZSTD_DCtx_loadDictionary() or ZSTD_DCtx_refPrefix() call, by disabling\n multiple-DDict mode, and by ZSTD_freeDCtx().\n Disabling multiple-DDict mode releases all dictionary references from the set;\n no dictionary from the set is retained for subsequent decompression.\n Referencing a DDict invalidates any previously loaded dictionary or prefix.\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."]
675 pub fn ZSTD_DCtx_refDDict(
676 dctx: *mut ZSTD_DCtx,
677 ddict: *const ZSTD_DDict,
678 ) -> usize;
679}
680extern "C" {
681 #[doc = " ZSTD_DCtx_refPrefix() : Requires v1.4.0+\n Reference a prefix (single-usage dictionary) for decompression.\n This is the reverse operation of ZSTD_CCtx_refPrefix(),\n and must use the same prefix as the one used during compression.\n The prefix is **only used once**:\n - ZSTD_decompressDCtx() uses it for exactly one call, including all frames\n in concatenated input. The call consumes the prefix even if the input\n is empty, contains only skippable frames, or produces an error.\n - ZSTD_decompressStream() uses it until the first frame is completely\n decoded and flushed, as indicated by a return value of 0. This includes\n empty and skippable frames, even though they produce no output.\n The explicit-dictionary functions ZSTD_decompress_usingDict() and\n ZSTD_decompress_usingDDict() use their dictionary argument instead and\n do not consume the prefix configured on the DCtx.\n\n ZSTD_DCtx_reset(dctx, ZSTD_reset_session_only) preserves an unused prefix\n if streaming decompression has not started. Once streaming has started,\n even with an incomplete header, a session-only reset abandons the frame\n and discards the prefix. After a streaming error the DCtx may be in an\n undefined state and must be reset before streaming can resume. Errors\n returned before streaming starts may leave an unused prefix installed.\n To unconditionally discard it, use ZSTD_reset_session_and_parameters,\n or ZSTD_reset_parameters when no frame is active. The latter can fail\n with ZSTD_error_stage_wrong during decompression.\n @result : 0, or an error code (which can be tested with ZSTD_isError()).\n Note 1 : Adding any prefix (including NULL or a zero-sized prefix) invalidates\n any previously set prefix or dictionary,\n including the multiple-DDict reference table.\n Successfully loading or referencing another dictionary, or calling\n ZSTD_initDStream(), also discards the prefix.\n Note 2 : Prefix buffer is referenced. It **must** outlive decompression.\n It must remain unmodified until the one-shot call returns, the\n streaming frame completes, or the prefix is explicitly discarded.\n Note 3 : By default, the prefix is treated as raw content (ZSTD_dct_rawContent).\n Use ZSTD_DCtx_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."]
682 pub fn ZSTD_DCtx_refPrefix(
683 dctx: *mut ZSTD_DCtx,
684 prefix: *const ::core::ffi::c_void,
685 prefixSize: usize,
686 ) -> usize;
687}
688extern "C" {
689 #[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."]
690 pub fn ZSTD_sizeof_CCtx(cctx: *const ZSTD_CCtx) -> usize;
691}
692extern "C" {
693 pub fn ZSTD_sizeof_DCtx(dctx: *const ZSTD_DCtx) -> usize;
694}
695extern "C" {
696 pub fn ZSTD_sizeof_CStream(zcs: *const ZSTD_CStream) -> usize;
697}
698extern "C" {
699 pub fn ZSTD_sizeof_DStream(zds: *const ZSTD_DStream) -> usize;
700}
701extern "C" {
702 pub fn ZSTD_sizeof_CDict(cdict: *const ZSTD_CDict) -> usize;
703}
704extern "C" {
705 pub fn ZSTD_sizeof_DDict(ddict: *const ZSTD_DDict) -> usize;
706}