@@ -51,6 +51,27 @@ use core::ops::{Deref, DerefMut};
5151use core:: ptr:: NonNull ;
5252use core:: str;
5353
54+ #[ macro_export]
55+ macro_rules! cfg_select {
56+ ( { $( $tt: tt) * } ) => { {
57+ $crate:: cfg_select! { $( $tt) * }
58+ } } ;
59+ ( _ => { $( $output: tt) * } ) => {
60+ $( $output) *
61+ } ;
62+ (
63+ $cfg: meta => $output: tt
64+ $( $( $rest: tt ) +) ?
65+ ) => {
66+ #[ cfg( $cfg) ]
67+ $crate:: cfg_select! { _ => $output }
68+ $(
69+ #[ cfg( not( $cfg) ) ]
70+ $crate:: cfg_select! { $( $rest) + }
71+ ) ?
72+ }
73+ }
74+
5475include ! ( "constants.rs" ) ;
5576
5677#[ cfg( feature = "experimental" ) ]
@@ -602,31 +623,78 @@ impl<'a> CCtx<'a> {
602623 ///
603624 /// Some of these parameters need to be set during de-compression as well.
604625 pub fn set_parameter ( & mut self , param : CParameter ) -> SafeResult {
605- // TODO: Until bindgen properly generates a binding for this, we'll need to do it here.
606-
607- #[ cfg( feature = "experimental" ) ]
608- use zstd_sys:: ZSTD_cParameter :: {
609- ZSTD_c_experimentalParam1 as ZSTD_c_rsyncable ,
610- ZSTD_c_experimentalParam10 as ZSTD_c_stableOutBuffer ,
611- ZSTD_c_experimentalParam11 as ZSTD_c_blockDelimiters ,
612- ZSTD_c_experimentalParam12 as ZSTD_c_validateSequences ,
613- ZSTD_c_experimentalParam13 as ZSTD_c_useBlockSplitter ,
614- ZSTD_c_experimentalParam14 as ZSTD_c_useRowMatchFinder ,
615- ZSTD_c_experimentalParam15 as ZSTD_c_deterministicRefPrefix ,
616- ZSTD_c_experimentalParam16 as ZSTD_c_prefetchCDictTables ,
617- ZSTD_c_experimentalParam17 as ZSTD_c_enableSeqProducerFallback ,
618- ZSTD_c_experimentalParam18 as ZSTD_c_maxBlockSize ,
619- ZSTD_c_experimentalParam19 as ZSTD_c_searchForExternalRepcodes ,
620- ZSTD_c_experimentalParam2 as ZSTD_c_format ,
621- ZSTD_c_experimentalParam3 as ZSTD_c_forceMaxWindow ,
622- ZSTD_c_experimentalParam4 as ZSTD_c_forceAttachDict ,
623- ZSTD_c_experimentalParam5 as ZSTD_c_literalCompressionMode ,
624- ZSTD_c_experimentalParam7 as ZSTD_c_srcSizeHint ,
625- ZSTD_c_experimentalParam8 as ZSTD_c_enableDedicatedDictSearch ,
626- ZSTD_c_experimentalParam9 as ZSTD_c_stableInBuffer ,
627- } ;
626+ #[ rustfmt:: skip]
627+ #[ allow( non_upper_case_globals, unused) ]
628+ mod helper {
629+ use zstd_sys:: ZSTD_cParameter ;
630+
631+ pub const ZSTD_c_chainLog : ZSTD_cParameter = ZSTD_cParameter :: ZSTD_c_chainLog ;
632+ pub const ZSTD_c_checksumFlag : ZSTD_cParameter = ZSTD_cParameter :: ZSTD_c_checksumFlag ;
633+ pub const ZSTD_c_compressionLevel : ZSTD_cParameter = ZSTD_cParameter :: ZSTD_c_compressionLevel ;
634+ pub const ZSTD_c_contentSizeFlag : ZSTD_cParameter = ZSTD_cParameter :: ZSTD_c_contentSizeFlag ;
635+ pub const ZSTD_c_dictIDFlag : ZSTD_cParameter = ZSTD_cParameter :: ZSTD_c_dictIDFlag ;
636+ pub const ZSTD_c_enableLongDistanceMatching : ZSTD_cParameter = ZSTD_cParameter :: ZSTD_c_enableLongDistanceMatching ;
637+ pub const ZSTD_c_experimentalParam1 : ZSTD_cParameter = ZSTD_cParameter :: ZSTD_c_experimentalParam1 ;
638+ pub const ZSTD_c_experimentalParam10 : ZSTD_cParameter = ZSTD_cParameter :: ZSTD_c_experimentalParam10 ;
639+ pub const ZSTD_c_experimentalParam11 : ZSTD_cParameter = ZSTD_cParameter :: ZSTD_c_experimentalParam11 ;
640+ pub const ZSTD_c_experimentalParam12 : ZSTD_cParameter = ZSTD_cParameter :: ZSTD_c_experimentalParam12 ;
641+ pub const ZSTD_c_experimentalParam13 : ZSTD_cParameter = ZSTD_cParameter :: ZSTD_c_experimentalParam13 ;
642+ pub const ZSTD_c_experimentalParam14 : ZSTD_cParameter = ZSTD_cParameter :: ZSTD_c_experimentalParam14 ;
643+ pub const ZSTD_c_experimentalParam15 : ZSTD_cParameter = ZSTD_cParameter :: ZSTD_c_experimentalParam15 ;
644+ pub const ZSTD_c_experimentalParam16 : ZSTD_cParameter = ZSTD_cParameter :: ZSTD_c_experimentalParam16 ;
645+ pub const ZSTD_c_experimentalParam17 : ZSTD_cParameter = ZSTD_cParameter :: ZSTD_c_experimentalParam17 ;
646+ pub const ZSTD_c_experimentalParam18 : ZSTD_cParameter = ZSTD_cParameter :: ZSTD_c_experimentalParam18 ;
647+ pub const ZSTD_c_experimentalParam19 : ZSTD_cParameter = ZSTD_cParameter :: ZSTD_c_experimentalParam19 ;
648+ pub const ZSTD_c_experimentalParam2 : ZSTD_cParameter = ZSTD_cParameter :: ZSTD_c_experimentalParam2 ;
649+ pub const ZSTD_c_experimentalParam20 : ZSTD_cParameter = ZSTD_cParameter :: ZSTD_c_experimentalParam20 ;
650+ pub const ZSTD_c_experimentalParam3 : ZSTD_cParameter = ZSTD_cParameter :: ZSTD_c_experimentalParam3 ;
651+ pub const ZSTD_c_experimentalParam4 : ZSTD_cParameter = ZSTD_cParameter :: ZSTD_c_experimentalParam4 ;
652+ pub const ZSTD_c_experimentalParam5 : ZSTD_cParameter = ZSTD_cParameter :: ZSTD_c_experimentalParam5 ;
653+ pub const ZSTD_c_experimentalParam7 : ZSTD_cParameter = ZSTD_cParameter :: ZSTD_c_experimentalParam7 ;
654+ pub const ZSTD_c_experimentalParam8 : ZSTD_cParameter = ZSTD_cParameter :: ZSTD_c_experimentalParam8 ;
655+ pub const ZSTD_c_experimentalParam9 : ZSTD_cParameter = ZSTD_cParameter :: ZSTD_c_experimentalParam9 ;
656+ pub const ZSTD_c_hashLog : ZSTD_cParameter = ZSTD_cParameter :: ZSTD_c_hashLog ;
657+ pub const ZSTD_c_jobSize : ZSTD_cParameter = ZSTD_cParameter :: ZSTD_c_jobSize ;
658+ pub const ZSTD_c_ldmBucketSizeLog : ZSTD_cParameter = ZSTD_cParameter :: ZSTD_c_ldmBucketSizeLog ;
659+ pub const ZSTD_c_ldmHashLog : ZSTD_cParameter = ZSTD_cParameter :: ZSTD_c_ldmHashLog ;
660+ pub const ZSTD_c_ldmHashRateLog : ZSTD_cParameter = ZSTD_cParameter :: ZSTD_c_ldmHashRateLog ;
661+ pub const ZSTD_c_ldmMinMatch : ZSTD_cParameter = ZSTD_cParameter :: ZSTD_c_ldmMinMatch ;
662+ pub const ZSTD_c_minMatch : ZSTD_cParameter = ZSTD_cParameter :: ZSTD_c_minMatch ;
663+ pub const ZSTD_c_nbWorkers : ZSTD_cParameter = ZSTD_cParameter :: ZSTD_c_nbWorkers ;
664+ pub const ZSTD_c_overlapLog : ZSTD_cParameter = ZSTD_cParameter :: ZSTD_c_overlapLog ;
665+ pub const ZSTD_c_searchLog : ZSTD_cParameter = ZSTD_cParameter :: ZSTD_c_searchLog ;
666+ pub const ZSTD_c_strategy : ZSTD_cParameter = ZSTD_cParameter :: ZSTD_c_strategy ;
667+ pub const ZSTD_c_targetCBlockSize : ZSTD_cParameter = ZSTD_cParameter :: ZSTD_c_targetCBlockSize ;
668+ pub const ZSTD_c_targetLength : ZSTD_cParameter = ZSTD_cParameter :: ZSTD_c_targetLength ;
669+ pub const ZSTD_c_windowLog : ZSTD_cParameter = ZSTD_cParameter :: ZSTD_c_windowLog ;
670+
671+ cfg_select ! (
672+ feature = "experimental" => {
673+ pub const ZSTD_c_rsyncable : ZSTD_cParameter = ZSTD_c_experimentalParam1 ;
674+ pub const ZSTD_c_stableOutBuffer : ZSTD_cParameter = ZSTD_c_experimentalParam10 ;
675+ pub const ZSTD_c_blockDelimiters : ZSTD_cParameter = ZSTD_c_experimentalParam11 ;
676+ pub const ZSTD_c_validateSequences : ZSTD_cParameter = ZSTD_c_experimentalParam12 ;
677+ pub const ZSTD_c_useBlockSplitter : ZSTD_cParameter = ZSTD_c_experimentalParam13 ;
678+ pub const ZSTD_c_useRowMatchFinder : ZSTD_cParameter = ZSTD_c_experimentalParam14 ;
679+ pub const ZSTD_c_deterministicRefPrefix : ZSTD_cParameter = ZSTD_c_experimentalParam15 ;
680+ pub const ZSTD_c_prefetchCDictTables : ZSTD_cParameter = ZSTD_c_experimentalParam16 ;
681+ pub const ZSTD_c_enableSeqProducerFallback : ZSTD_cParameter = ZSTD_c_experimentalParam17 ;
682+ pub const ZSTD_c_maxBlockSize : ZSTD_cParameter = ZSTD_c_experimentalParam18 ;
683+ pub const ZSTD_c_searchForExternalRepcodes : ZSTD_cParameter = ZSTD_c_experimentalParam19 ;
684+ pub const ZSTD_c_format : ZSTD_cParameter = ZSTD_c_experimentalParam2 ;
685+ pub const ZSTD_c_forceMaxWindow : ZSTD_cParameter = ZSTD_c_experimentalParam3 ;
686+ pub const ZSTD_c_forceAttachDict : ZSTD_cParameter = ZSTD_c_experimentalParam4 ;
687+ pub const ZSTD_c_literalCompressionMode : ZSTD_cParameter = ZSTD_c_experimentalParam5 ;
688+ pub const ZSTD_c_srcSizeHint : ZSTD_cParameter = ZSTD_c_experimentalParam7 ;
689+ pub const ZSTD_c_enableDedicatedDictSearch : ZSTD_cParameter = ZSTD_c_experimentalParam8 ;
690+ pub const ZSTD_c_stableInBuffer : ZSTD_cParameter = ZSTD_c_experimentalParam9 ;
691+ }
692+
693+ _ => { }
694+ ) ;
695+ }
628696
629- use zstd_sys :: ZSTD_cParameter :: * ;
697+ pub use helper :: * ;
630698 use CParameter :: * ;
631699
632700 let ( param, value) = match param {
@@ -1125,15 +1193,32 @@ impl<'a> DCtx<'a> {
11251193
11261194 /// Sets a decompression parameter.
11271195 pub fn set_parameter ( & mut self , param : DParameter ) -> SafeResult {
1128- #[ cfg( feature = "experimental" ) ]
1129- use zstd_sys:: ZSTD_dParameter :: {
1130- ZSTD_d_experimentalParam1 as ZSTD_d_format ,
1131- ZSTD_d_experimentalParam2 as ZSTD_d_stableOutBuffer ,
1132- ZSTD_d_experimentalParam3 as ZSTD_d_forceIgnoreChecksum ,
1133- ZSTD_d_experimentalParam4 as ZSTD_d_refMultipleDDicts ,
1134- } ;
1196+ #[ rustfmt:: skip]
1197+ #[ allow( unused, non_upper_case_globals) ]
1198+ mod helper {
1199+ use zstd_sys:: ZSTD_dParameter ;
1200+
1201+ pub const ZSTD_d_windowLogMax : ZSTD_dParameter = ZSTD_dParameter :: ZSTD_d_windowLogMax ;
1202+ pub const ZSTD_d_experimentalParam1 : ZSTD_dParameter = ZSTD_dParameter :: ZSTD_d_experimentalParam1 ;
1203+ pub const ZSTD_d_experimentalParam2 : ZSTD_dParameter = ZSTD_dParameter :: ZSTD_d_experimentalParam2 ;
1204+ pub const ZSTD_d_experimentalParam3 : ZSTD_dParameter = ZSTD_dParameter :: ZSTD_d_experimentalParam3 ;
1205+ pub const ZSTD_d_experimentalParam4 : ZSTD_dParameter = ZSTD_dParameter :: ZSTD_d_experimentalParam4 ;
1206+ pub const ZSTD_d_experimentalParam5 : ZSTD_dParameter = ZSTD_dParameter :: ZSTD_d_experimentalParam5 ;
1207+ pub const ZSTD_d_experimentalParam6 : ZSTD_dParameter = ZSTD_dParameter :: ZSTD_d_experimentalParam6 ;
1208+
1209+ cfg_select ! (
1210+ feature = "experimental" => {
1211+ pub const ZSTD_d_format : ZSTD_dParameter = ZSTD_d_experimentalParam1 ;
1212+ pub const ZSTD_d_stableOutBuffer : ZSTD_dParameter = ZSTD_d_experimentalParam2 ;
1213+ pub const ZSTD_d_forceIgnoreChecksum : ZSTD_dParameter = ZSTD_d_experimentalParam3 ;
1214+ pub const ZSTD_d_refMultipleDDicts : ZSTD_dParameter = ZSTD_d_experimentalParam4 ;
1215+ }
1216+
1217+ _ => { }
1218+ ) ;
1219+ }
11351220
1136- use zstd_sys :: ZSTD_dParameter :: * ;
1221+ use helper :: * ;
11371222 use DParameter :: * ;
11381223
11391224 let ( param, value) = match param {
0 commit comments