zstd_sys/
bindings_zdict_std.rs

1// Copyright 2024 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Generated by third_party/rust_crates/forks/zstd-sys/bindgen.sh using bindgen 0.71.1
6
7unsafe extern "C" {
8    /// ZDICT_trainFromBuffer():
9    ///  Train a dictionary from an array of samples.
10    ///  Redirect towards ZDICT_optimizeTrainFromBuffer_fastCover() single-threaded, with d=8, steps=4,
11    ///  f=20, and accel=1.
12    ///  Samples must be stored concatenated in a single flat buffer `samplesBuffer`,
13    ///  supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order.
14    ///  The resulting dictionary will be saved into `dictBuffer`.
15    /// @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)
16    ///          or an error code, which can be tested with ZDICT_isError().
17    ///  Note:  Dictionary training will fail if there are not enough samples to construct a
18    ///         dictionary, or if most of the samples are too small (< 8 bytes being the lower limit).
19    ///         If dictionary training fails, you should use zstd without a dictionary, as the dictionary
20    ///         would've been ineffective anyways. If you believe your samples would benefit from a dictionary
21    ///         please open an issue with details, and we can look into it.
22    ///  Note: ZDICT_trainFromBuffer()'s memory usage is about 6 MB.
23    ///  Tips: In general, a reasonable dictionary has a size of ~ 100 KB.
24    ///        It's possible to select smaller or larger size, just by specifying `dictBufferCapacity`.
25    ///        In general, it's recommended to provide a few thousands samples, though this can vary a lot.
26    ///        It's recommended that total size of all samples be about ~x100 times the target size of dictionary.
27    pub fn ZDICT_trainFromBuffer(
28        dictBuffer: *mut ::core::ffi::c_void,
29        dictBufferCapacity: usize,
30        samplesBuffer: *const ::core::ffi::c_void,
31        samplesSizes: *const usize,
32        nbSamples: ::core::ffi::c_uint,
33    ) -> usize;
34}
35#[repr(C)]
36#[derive(Debug, Copy, Clone)]
37pub struct ZDICT_params_t {
38    ///< optimize for a specific zstd compression level; 0 means default
39    pub compressionLevel: ::core::ffi::c_int,
40    ///< Write log to stderr; 0 = none (default); 1 = errors; 2 = progression; 3 = details; 4 = debug;
41    pub notificationLevel: ::core::ffi::c_uint,
42    ///< force dictID value; 0 means auto mode (32-bits random value)
43    ///   NOTE: The zstd format reserves some dictionary IDs for future use.
44    ///         You may use them in private settings, but be warned that they
45    ///         may be used by zstd in a public dictionary registry in the future.
46    ///         These dictionary IDs are:
47    ///           - low range  : <= 32767
48    ///           - high range : >= (2^31)
49    pub dictID: ::core::ffi::c_uint,
50}
51unsafe extern "C" {
52    /// ZDICT_finalizeDictionary():
53    /// Given a custom content as a basis for dictionary, and a set of samples,
54    /// finalize dictionary by adding headers and statistics according to the zstd
55    /// dictionary format.
56    ///
57    /// Samples must be stored concatenated in a flat buffer `samplesBuffer`,
58    /// supplied with an array of sizes `samplesSizes`, providing the size of each
59    /// sample in order. The samples are used to construct the statistics, so they
60    /// should be representative of what you will compress with this dictionary.
61    ///
62    /// The compression level can be set in `parameters`. You should pass the
63    /// compression level you expect to use in production. The statistics for each
64    /// compression level differ, so tuning the dictionary for the compression level
65    /// can help quite a bit.
66    ///
67    /// You can set an explicit dictionary ID in `parameters`, or allow us to pick
68    /// a random dictionary ID for you, but we can't guarantee no collisions.
69    ///
70    /// The dstDictBuffer and the dictContent may overlap, and the content will be
71    /// appended to the end of the header. If the header + the content doesn't fit in
72    /// maxDictSize the beginning of the content is truncated to make room, since it
73    /// is presumed that the most profitable content is at the end of the dictionary,
74    /// since that is the cheapest to reference.
75    ///
76    /// `maxDictSize` must be >= max(dictContentSize, ZSTD_DICTSIZE_MIN).
77    ///
78    /// @return: size of dictionary stored into `dstDictBuffer` (<= `maxDictSize`),
79    ///          or an error code, which can be tested by ZDICT_isError().
80    /// Note: ZDICT_finalizeDictionary() will push notifications into stderr if
81    ///       instructed to, using notificationLevel>0.
82    /// NOTE: This function currently may fail in several edge cases including:
83    ///         * Not enough samples
84    ///         * Samples are uncompressible
85    ///         * Samples are all exactly the same
86    pub fn ZDICT_finalizeDictionary(
87        dstDictBuffer: *mut ::core::ffi::c_void,
88        maxDictSize: usize,
89        dictContent: *const ::core::ffi::c_void,
90        dictContentSize: usize,
91        samplesBuffer: *const ::core::ffi::c_void,
92        samplesSizes: *const usize,
93        nbSamples: ::core::ffi::c_uint,
94        parameters: ZDICT_params_t,
95    ) -> usize;
96}
97unsafe extern "C" {
98    pub fn ZDICT_getDictID(
99        dictBuffer: *const ::core::ffi::c_void,
100        dictSize: usize,
101    ) -> ::core::ffi::c_uint;
102}
103unsafe extern "C" {
104    pub fn ZDICT_getDictHeaderSize(
105        dictBuffer: *const ::core::ffi::c_void,
106        dictSize: usize,
107    ) -> usize;
108}
109unsafe extern "C" {
110    pub fn ZDICT_isError(errorCode: usize) -> ::core::ffi::c_uint;
111}
112unsafe extern "C" {
113    pub fn ZDICT_getErrorName(errorCode: usize) -> *const ::core::ffi::c_char;
114}