1
1
//! This module contains zstd-specific types for async-compression.
2
2
3
- use libzstd:: stream:: raw:: CParameter :: * ;
4
- use libzstd:: stream:: raw:: DParameter :: * ;
5
-
6
3
/// A compression parameter for zstd. This is a stable wrapper around zstd's own `CParameter`
7
4
/// type, to abstract over different versions of the zstd library.
8
5
///
@@ -14,74 +11,74 @@ pub struct CParameter(libzstd::stream::raw::CParameter);
14
11
impl CParameter {
15
12
/// Window size in bytes (as a power of two)
16
13
pub fn window_log ( value : u32 ) -> Self {
17
- Self ( WindowLog ( value) )
14
+ Self ( libzstd :: stream :: raw :: CParameter :: WindowLog ( value) )
18
15
}
19
16
20
17
/// Size of the initial probe table in 4-byte entries (as a power of two)
21
18
pub fn hash_log ( value : u32 ) -> Self {
22
- Self ( HashLog ( value) )
19
+ Self ( libzstd :: stream :: raw :: CParameter :: HashLog ( value) )
23
20
}
24
21
25
22
/// Size of the multi-probe table in 4-byte entries (as a power of two)
26
23
pub fn chain_log ( value : u32 ) -> Self {
27
- Self ( ChainLog ( value) )
24
+ Self ( libzstd :: stream :: raw :: CParameter :: ChainLog ( value) )
28
25
}
29
26
30
27
/// Number of search attempts (as a power of two)
31
28
pub fn search_log ( value : u32 ) -> Self {
32
- Self ( SearchLog ( value) )
29
+ Self ( libzstd :: stream :: raw :: CParameter :: SearchLog ( value) )
33
30
}
34
31
35
32
/// Minimum size of matches searched for
36
33
pub fn min_match ( value : u32 ) -> Self {
37
- Self ( MinMatch ( value) )
34
+ Self ( libzstd :: stream :: raw :: CParameter :: MinMatch ( value) )
38
35
}
39
36
40
37
/// Strategy-dependent length modifier
41
38
pub fn target_length ( value : u32 ) -> Self {
42
- Self ( TargetLength ( value) )
39
+ Self ( libzstd :: stream :: raw :: CParameter :: TargetLength ( value) )
43
40
}
44
41
45
42
/// Enable long-distance matching mode to look for and emit long-distance references.
46
43
///
47
44
/// This increases the default window size.
48
45
pub fn enable_long_distance_matching ( value : bool ) -> Self {
49
- Self ( EnableLongDistanceMatching ( value) )
46
+ Self ( libzstd :: stream :: raw :: CParameter :: EnableLongDistanceMatching ( value) )
50
47
}
51
48
52
49
/// Size of the long-distance matching table (as a power of two)
53
50
pub fn ldm_hash_log ( value : u32 ) -> Self {
54
- Self ( LdmHashLog ( value) )
51
+ Self ( libzstd :: stream :: raw :: CParameter :: LdmHashLog ( value) )
55
52
}
56
53
57
54
/// Minimum size of long-distance matches searched for
58
55
pub fn ldm_min_match ( value : u32 ) -> Self {
59
- Self ( LdmMinMatch ( value) )
56
+ Self ( libzstd :: stream :: raw :: CParameter :: LdmMinMatch ( value) )
60
57
}
61
58
62
59
/// Size of each bucket in the LDM hash table for collision resolution (as a power of two)
63
60
pub fn ldm_bucket_size_log ( value : u32 ) -> Self {
64
- Self ( LdmBucketSizeLog ( value) )
61
+ Self ( libzstd :: stream :: raw :: CParameter :: LdmBucketSizeLog ( value) )
65
62
}
66
63
67
64
/// Frequency of using the LDM hash table (as a power of two)
68
65
pub fn ldm_hash_rate_log ( value : u32 ) -> Self {
69
- Self ( LdmHashRateLog ( value) )
66
+ Self ( libzstd :: stream :: raw :: CParameter :: LdmHashRateLog ( value) )
70
67
}
71
68
72
69
/// Emit the size of the content (default: true).
73
70
pub fn content_size_flag ( value : bool ) -> Self {
74
- Self ( ContentSizeFlag ( value) )
71
+ Self ( libzstd :: stream :: raw :: CParameter :: ContentSizeFlag ( value) )
75
72
}
76
73
77
74
/// Emit a checksum (default: false).
78
75
pub fn checksum_flag ( value : bool ) -> Self {
79
- Self ( ChecksumFlag ( value) )
76
+ Self ( libzstd :: stream :: raw :: CParameter :: ChecksumFlag ( value) )
80
77
}
81
78
82
79
/// Emit a dictionary ID when using a custom dictionary (default: true).
83
80
pub fn dict_id_flag ( value : bool ) -> Self {
84
- Self ( DictIdFlag ( value) )
81
+ Self ( libzstd :: stream :: raw :: CParameter :: DictIdFlag ( value) )
85
82
}
86
83
87
84
/// Number of threads to spawn.
@@ -97,14 +94,14 @@ impl CParameter {
97
94
// TODO: make this a normal feature guarded fn on next breaking release
98
95
#[ cfg_attr( docsrs, doc( cfg( feature = "zstdmt" ) ) ) ]
99
96
pub fn nb_workers ( value : u32 ) -> Self {
100
- Self ( NbWorkers ( value) )
97
+ Self ( libzstd :: stream :: raw :: CParameter :: NbWorkers ( value) )
101
98
}
102
99
103
100
/// Number of bytes given to each worker.
104
101
///
105
102
/// If set to 0, zstd selects a job size based on compression parameters.
106
103
pub fn job_size ( value : u32 ) -> Self {
107
- Self ( JobSize ( value) )
104
+ Self ( libzstd :: stream :: raw :: CParameter :: JobSize ( value) )
108
105
}
109
106
110
107
pub ( crate ) fn as_zstd ( & self ) -> libzstd:: stream:: raw:: CParameter {
@@ -123,7 +120,7 @@ pub struct DParameter(libzstd::stream::raw::DParameter);
123
120
impl DParameter {
124
121
/// Maximum window size in bytes (as a power of two)
125
122
pub fn window_log_max ( value : u32 ) -> Self {
126
- Self ( WindowLogMax ( value) )
123
+ Self ( libzstd :: stream :: raw :: DParameter :: WindowLogMax ( value) )
127
124
}
128
125
129
126
pub ( crate ) fn as_zstd ( & self ) -> libzstd:: stream:: raw:: DParameter {
0 commit comments