Skip to content

Commit 72e9f37

Browse files
michielp1807folkertdev
authored andcommitted
Add documentation to structs in zdict.rs
1 parent a24280b commit 72e9f37

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

lib/zdict.rs

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
11
#[derive(Debug, Copy, Clone, Default)]
22
#[repr(C)]
33
pub struct ZDICT_params_t {
4+
/// Choose which zstd compression level to optimize for.
5+
///
6+
/// 0 means default ([`crate::ZSTD_CLEVEL_DEFAULT`]).
47
pub compressionLevel: core::ffi::c_int,
8+
/// Choose which logs to write to stderr:
9+
///
10+
/// - 0 none (default)
11+
/// - 1 errors
12+
/// - 2 progression
13+
/// - 3 details
14+
/// - 4 debug
515
pub notificationLevel: core::ffi::c_uint,
16+
/// Force a `dictID` value.
17+
///
18+
/// 0 means automatic mode (32-bits random value).
19+
///
20+
/// Note: the zstd format reserves some dictionary IDs for future use. You may use them in
21+
/// private settings, but be warned that they may be used by zstd in a public dictionary
22+
/// registry in the future. The reserved dictionary IDs are:
23+
/// - low range: <= 32767
24+
/// - high range: >= (2^31)
625
pub dictID: core::ffi::c_uint,
726
}
827

@@ -19,30 +38,77 @@ pub mod experimental {
1938
#[deprecated = "will be removed in v1.6.0"]
2039
pub const ZDICT_CONTENTSIZE_MIN: core::ffi::c_int = 128;
2140

41+
/// `k` and `d` are the only required parameters. For others, value 0 means default.
2242
#[derive(Debug, Copy, Clone, Default)]
2343
#[repr(C)]
2444
pub struct ZDICT_cover_params_t {
45+
/// Set the segment size `0 < k`. (reasonable range \[16, 2048+])
2546
pub k: core::ffi::c_uint,
47+
/// Set the dmer size `0 < d <= k`. (reasonable range \[6, 16])
2648
pub d: core::ffi::c_uint,
49+
/// Set the number of steps (only used for optimization).
50+
///
51+
/// 0 means default (40), higher means more parameters checked.
2752
pub steps: core::ffi::c_uint,
53+
/// Set the number of threads `0 < nbThreads` (only used for optimization).
54+
///
55+
/// 1 means single-threaded.
2856
pub nbThreads: core::ffi::c_uint,
57+
/// Set the percentage of samples used for training (only used for optimization).
58+
///
59+
/// The first `nbSamples * splitPoint` samples will be used to training, the last
60+
/// `nbSamples * (1 - splitPoint)` samples will be used for testing.
61+
///
62+
/// 0.0 means default (1.0), 1.0 means all samples are used for both training and testing.
2963
pub splitPoint: core::ffi::c_double,
64+
/// Train dictionaries to shrink in size starting from the minimum size and selects the
65+
/// smallest dictionary that is `shrinkDictMaxRegression%` worse than the largest dictionary.
66+
///
67+
/// 0 means no shrinking and 1 means shrinking.
3068
pub shrinkDict: core::ffi::c_uint,
69+
/// Set the maximum regression so that a smaller dictionary can be no more than
70+
/// `shrinkDictMaxRegression%` worse than the max dict size dictionary.
3171
pub shrinkDictMaxRegression: core::ffi::c_uint,
3272
pub zParams: ZDICT_params_t,
3373
}
3474

3575
#[derive(Debug, Copy, Clone, Default)]
3676
#[repr(C)]
3777
pub struct ZDICT_fastCover_params_t {
78+
/// Segment size `0 < k` (reasonable range \[16, 2048+])
3879
pub k: core::ffi::c_uint,
80+
/// dmer size `0 < d <= k` (reasonable range \[6, 16])
3981
pub d: core::ffi::c_uint,
82+
/// log of frequency array size `0 < f <= 31`
83+
///
84+
/// 1 means default (20).
4085
pub f: core::ffi::c_uint,
86+
/// Number of steps (only used for optimization)
87+
///
88+
/// 0 means default (40), higher means more parameters checked.
4189
pub steps: core::ffi::c_uint,
90+
/// Number of threads `0 < nbThreads` (only used for optimization)
91+
///
92+
/// 1 means single-threaded.
4293
pub nbThreads: core::ffi::c_uint,
94+
/// Percentage of samples used for training (only used for optimization)
95+
///
96+
/// The first `nbSamples * splitPoint` samples will be used to training, the last
97+
/// `nbSamples * (1 - splitPoint)` samples will be used for testing.
98+
///
99+
/// 0.0 means default (0.75), 1.0 means all samples are used for both training and testing.
43100
pub splitPoint: core::ffi::c_double,
101+
/// Acceleration level `0 < accel <= 10`
102+
///
103+
/// Higher means faster and less accurate, 0 means default (1).
44104
pub accel: core::ffi::c_uint,
105+
/// Train dictionaries to shrink in size starting from the minimum size and selects the
106+
/// smallest dictionary that is `shrinkDictMaxRegression%` worse than the largest dictionary.
107+
///
108+
/// 0 means no shrinking and 1 means shrinking.
45109
pub shrinkDict: core::ffi::c_uint,
110+
/// Sets shrinkDictMaxRegression so that a smaller dictionary can be at worse
111+
/// `shrinkDictMaxRegression%` worse than the max dict size dictionary.
46112
pub shrinkDictMaxRegression: core::ffi::c_uint,
47113
pub zParams: ZDICT_params_t,
48114
}
@@ -57,6 +123,7 @@ pub mod experimental {
57123
#[derive(Debug, Copy, Clone, Default)]
58124
#[repr(C)]
59125
pub struct ZDICT_legacy_params_t {
126+
/// 0 means default (9); larger means it will select more, so you will get a larger dictionary.
60127
pub selectivityLevel: core::ffi::c_uint,
61128
pub zParams: ZDICT_params_t,
62129
}

0 commit comments

Comments
 (0)