mirror of
https://github.com/gyscos/zstd-rs
synced 2024-10-18 13:52:51 +00:00
Update to zstd 1.3.6
This commit is contained in:
parent
43655c120c
commit
c283d37a2d
|
@ -7,7 +7,7 @@ categories = ["compression", "api-bindings"]
|
|||
license = "MIT"
|
||||
name = "zstd"
|
||||
repository = "https://github.com/gyscos/zstd-rs"
|
||||
version = "0.4.19+zstd.1.3.5"
|
||||
version = "0.4.20+zstd.1.3.6"
|
||||
exclude = ["assets/**"]
|
||||
readme = "Readme.md"
|
||||
|
||||
|
@ -15,7 +15,7 @@ readme = "Readme.md"
|
|||
travis-ci = { repository = "gyscos/zstd-rs" }
|
||||
|
||||
[dependencies]
|
||||
zstd-safe = { path="zstd-safe", version = "1.4.4", default-features = false }
|
||||
zstd-safe = { path="zstd-safe", version = "1.4.5", default-features = false }
|
||||
tokio-io = { version = "0.1", optional = true }
|
||||
futures = { version = "0.1", optional = true }
|
||||
|
||||
|
@ -24,6 +24,7 @@ clap = "2.6.0"
|
|||
partial-io = "^0.2.1"
|
||||
quickcheck = "0.4"
|
||||
humansize = "1.0"
|
||||
walkdir = "2.2.5"
|
||||
|
||||
[features]
|
||||
default = ["legacy"]
|
||||
|
|
17
src/dict.rs
17
src/dict.rs
|
@ -136,13 +136,15 @@ mod tests {
|
|||
use std::io;
|
||||
use std::io::Read;
|
||||
|
||||
extern crate walkdir;
|
||||
|
||||
#[test]
|
||||
fn test_dict_training() {
|
||||
// Train a dictionary
|
||||
let paths: Vec<_> = fs::read_dir("src")
|
||||
.unwrap()
|
||||
let paths: Vec<_> = walkdir::WalkDir::new("src")
|
||||
.into_iter()
|
||||
.map(|entry| entry.unwrap())
|
||||
.map(|entry| entry.path())
|
||||
.map(|entry| entry.into_path())
|
||||
.filter(|path| path.to_str().unwrap().ends_with(".rs"))
|
||||
.collect();
|
||||
|
||||
|
@ -158,16 +160,19 @@ mod tests {
|
|||
&mut ::stream::Encoder::with_dictionary(&mut buffer, 1, &dict)
|
||||
.unwrap()
|
||||
.auto_finish(),
|
||||
).unwrap();
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let mut result = Vec::new();
|
||||
io::copy(
|
||||
&mut ::stream::Decoder::with_dictionary(
|
||||
&buffer[..],
|
||||
&dict[..],
|
||||
).unwrap(),
|
||||
)
|
||||
.unwrap(),
|
||||
&mut result,
|
||||
).unwrap();
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(&content, &result);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
authors = ["Alexandre Bury <alexandre.bury@gmail.com>"]
|
||||
name = "zstd-safe"
|
||||
version = "1.4.4+zstd.1.3.5"
|
||||
version = "1.4.5+zstd.1.3.6"
|
||||
description = "Safe low-level bindings for the zstd compression library."
|
||||
keywords = ["zstd", "zstandard", "compression"]
|
||||
categories = ["api-bindings", "compression"]
|
||||
|
@ -10,7 +10,7 @@ license = "MIT/Apache-2.0"
|
|||
readme = "Readme.md"
|
||||
|
||||
[dependencies]
|
||||
zstd-sys = { path="zstd-sys", version = "1.4.4", default-features = false }
|
||||
zstd-sys = { path="zstd-sys", version = "1.4.5", default-features = false }
|
||||
libc = "0.2.21"
|
||||
|
||||
[features]
|
||||
|
|
|
@ -16,7 +16,7 @@ links = "zstd"
|
|||
name = "zstd-sys"
|
||||
readme = "Readme.md"
|
||||
repository = "https://github.com/gyscos/zstd-rs"
|
||||
version = "1.4.4+zstd.1.3.5"
|
||||
version = "1.4.5+zstd.1.3.6"
|
||||
|
||||
[build-dependencies]
|
||||
blob = "0.2.0"
|
||||
|
@ -25,7 +25,7 @@ glob = "0.2.11"
|
|||
|
||||
[build-dependencies.bindgen]
|
||||
optional = true
|
||||
version = "0.37"
|
||||
version = "0.42"
|
||||
|
||||
[dependencies]
|
||||
libc = "0.2.21"
|
||||
|
|
|
@ -2,14 +2,16 @@
|
|||
|
||||
pub const ZSTD_VERSION_MAJOR: u32 = 1;
|
||||
pub const ZSTD_VERSION_MINOR: u32 = 3;
|
||||
pub const ZSTD_VERSION_RELEASE: u32 = 5;
|
||||
pub const ZSTD_VERSION_NUMBER: u32 = 10305;
|
||||
pub const ZSTD_VERSION_RELEASE: u32 = 6;
|
||||
pub const ZSTD_VERSION_NUMBER: u32 = 10306;
|
||||
pub const ZSTD_CLEVEL_DEFAULT: u32 = 3;
|
||||
pub const ZSTD_CONTENTSIZE_UNKNOWN: i32 = -1;
|
||||
pub const ZSTD_CONTENTSIZE_ERROR: i32 = -2;
|
||||
pub const ZSTD_MAGICNUMBER: u32 = 4247762216;
|
||||
pub const ZSTD_MAGIC_SKIPPABLE_START: u32 = 407710288;
|
||||
pub const ZSTD_MAGIC_DICTIONARY: u32 = 3962610743;
|
||||
pub const ZSTD_MAGIC_SKIPPABLE_START: u32 = 407710288;
|
||||
pub const ZSTD_BLOCKSIZELOG_MAX: u32 = 17;
|
||||
pub const ZSTD_BLOCKSIZE_MAX: u32 = 131072;
|
||||
pub const ZSTD_WINDOWLOG_MAX_32: u32 = 30;
|
||||
pub const ZSTD_WINDOWLOG_MAX_64: u32 = 31;
|
||||
pub const ZSTD_WINDOWLOG_MIN: u32 = 10;
|
||||
|
@ -21,14 +23,14 @@ pub const ZSTD_HASHLOG3_MAX: u32 = 17;
|
|||
pub const ZSTD_SEARCHLOG_MIN: u32 = 1;
|
||||
pub const ZSTD_SEARCHLENGTH_MAX: u32 = 7;
|
||||
pub const ZSTD_SEARCHLENGTH_MIN: u32 = 3;
|
||||
pub const ZSTD_LDM_MINMATCH_MIN: u32 = 4;
|
||||
pub const ZSTD_TARGETLENGTH_MAX: u32 = 131072;
|
||||
pub const ZSTD_TARGETLENGTH_MIN: u32 = 0;
|
||||
pub const ZSTD_LDM_MINMATCH_MAX: u32 = 4096;
|
||||
pub const ZSTD_LDM_MINMATCH_MIN: u32 = 4;
|
||||
pub const ZSTD_LDM_BUCKETSIZELOG_MAX: u32 = 8;
|
||||
pub const ZSTD_FRAMEHEADERSIZE_PREFIX: u32 = 5;
|
||||
pub const ZSTD_FRAMEHEADERSIZE_MIN: u32 = 6;
|
||||
pub const ZSTD_FRAMEHEADERSIZE_MAX: u32 = 18;
|
||||
pub const ZSTD_BLOCKSIZELOG_MAX: u32 = 17;
|
||||
pub const ZSTD_BLOCKSIZE_MAX: u32 = 131072;
|
||||
pub const ZSTDMT_JOBSIZE_MIN: u32 = 1048576;
|
||||
pub type wchar_t = ::libc::c_int;
|
||||
extern "C" {
|
||||
|
@ -39,8 +41,8 @@ extern "C" {
|
|||
}
|
||||
extern "C" {
|
||||
/// Simple API
|
||||
/// /
|
||||
/// /*! ZSTD_compress() :
|
||||
////
|
||||
////*! ZSTD_compress() :
|
||||
/// Compresses `src` content as a single zstd compressed frame into already allocated `dst`.
|
||||
/// Hint : compression runs faster if `dstCapacity` >= `ZSTD_compressBound(srcSize)`.
|
||||
/// @return : compressed size written into `dst` (<= `dstCapacity),
|
||||
|
@ -147,8 +149,8 @@ extern "C" {
|
|||
}
|
||||
extern "C" {
|
||||
/// Simple dictionary API
|
||||
/// /
|
||||
/// /*! ZSTD_compress_usingDict() :
|
||||
////
|
||||
////*! ZSTD_compress_usingDict() :
|
||||
/// Compression using a predefined Dictionary (see dictBuilder/zdict.h).
|
||||
/// Note : This function loads the dictionary, resulting in significant startup delay.
|
||||
/// Note : When `dict == NULL || dictSize < 8` no dictionary is used.
|
||||
|
@ -192,6 +194,7 @@ extern "C" {
|
|||
/// ZSTD_createCDict() will create a digested dictionary, ready to start future compression operations without startup delay.
|
||||
/// ZSTD_CDict can be created once and shared by multiple threads concurrently, since its usage is read-only.
|
||||
/// `dictBuffer` can be released after ZSTD_CDict creation, since its content is copied within CDict
|
||||
/// Note : A ZSTD_CDict can be created with an empty dictionary, but it is inefficient for small data.
|
||||
pub fn ZSTD_createCDict(
|
||||
dictBuffer: *const ::libc::c_void,
|
||||
dictSize: usize,
|
||||
|
@ -209,6 +212,8 @@ extern "C" {
|
|||
/// Faster startup than ZSTD_compress_usingDict(), recommended when same dictionary is used multiple times.
|
||||
/// Note that compression level is decided during dictionary creation.
|
||||
/// Frame parameters are hardcoded (dictID=yes, contentSize=yes, checksum=no)
|
||||
/// Note : ZSTD_compress_usingCDict() can be used with a ZSTD_CDict created from an empty dictionary.
|
||||
/// But it is inefficient for small data, and it is recommended to use ZSTD_compressCCtx().
|
||||
pub fn ZSTD_compress_usingCDict(
|
||||
cctx: *mut ZSTD_CCtx,
|
||||
dst: *mut ::libc::c_void,
|
||||
|
@ -255,11 +260,11 @@ extern "C" {
|
|||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct ZSTD_inBuffer_s {
|
||||
/// < start of input buffer
|
||||
///< start of input buffer
|
||||
pub src: *const ::libc::c_void,
|
||||
/// < size of input buffer
|
||||
///< size of input buffer
|
||||
pub size: usize,
|
||||
/// < position where reading stopped. Will be updated. Necessarily 0 <= pos <= size
|
||||
///< position where reading stopped. Will be updated. Necessarily 0 <= pos <= size
|
||||
pub pos: usize,
|
||||
}
|
||||
#[test]
|
||||
|
@ -318,11 +323,11 @@ pub type ZSTD_inBuffer = ZSTD_inBuffer_s;
|
|||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct ZSTD_outBuffer_s {
|
||||
/// < start of output buffer
|
||||
///< start of output buffer
|
||||
pub dst: *mut ::libc::c_void,
|
||||
/// < size of output buffer
|
||||
///< size of output buffer
|
||||
pub size: usize,
|
||||
/// < position where writing stopped. Will be updated. Necessarily 0 <= pos <= size
|
||||
///< position where writing stopped. Will be updated. Necessarily 0 <= pos <= size
|
||||
pub pos: usize,
|
||||
}
|
||||
#[test]
|
||||
|
@ -439,6 +444,15 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn ZSTD_DStreamOutSize() -> usize;
|
||||
}
|
||||
extern "C" {
|
||||
/// ADVANCED AND EXPERIMENTAL FUNCTIONS
|
||||
///
|
||||
/// The definitions in this section are considered experimental.
|
||||
/// They should never be used with a dynamic library, as prototypes may change in the future.
|
||||
/// They are provided for advanced scenarios.
|
||||
/// Use them only in association with static linking.
|
||||
pub fn ZSTD_minCLevel() -> ::libc::c_int;
|
||||
}
|
||||
pub const ZSTD_frameHeaderSize_prefix: usize = 5;
|
||||
pub const ZSTD_frameHeaderSize_min: usize = 6;
|
||||
pub const ZSTD_frameHeaderSize_max: usize = 18;
|
||||
|
@ -458,17 +472,17 @@ pub enum ZSTD_strategy {
|
|||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct ZSTD_compressionParameters {
|
||||
/// < largest match distance : larger == more compression, more memory needed during decompression
|
||||
///< largest match distance : larger == more compression, more memory needed during decompression
|
||||
pub windowLog: ::libc::c_uint,
|
||||
/// < fully searched segment : larger == more compression, slower, more memory (useless for fast)
|
||||
///< fully searched segment : larger == more compression, slower, more memory (useless for fast)
|
||||
pub chainLog: ::libc::c_uint,
|
||||
/// < dispatch table : larger == faster, more memory
|
||||
///< dispatch table : larger == faster, more memory
|
||||
pub hashLog: ::libc::c_uint,
|
||||
/// < nb of searches : larger == more compression, slower
|
||||
///< nb of searches : larger == more compression, slower
|
||||
pub searchLog: ::libc::c_uint,
|
||||
/// < match length searched : larger == faster decompression, sometimes less compression
|
||||
///< match length searched : larger == faster decompression, sometimes less compression
|
||||
pub searchLength: ::libc::c_uint,
|
||||
/// < acceptable match size for optimal parser (only) : larger == more compression, slower
|
||||
///< acceptable match size for optimal parser (only) : larger == more compression, slower
|
||||
pub targetLength: ::libc::c_uint,
|
||||
pub strategy: ZSTD_strategy,
|
||||
}
|
||||
|
@ -579,11 +593,11 @@ fn bindgen_test_layout_ZSTD_compressionParameters() {
|
|||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct ZSTD_frameParameters {
|
||||
/// < 1: content size will be in frame header (when known)
|
||||
///< 1: content size will be in frame header (when known)
|
||||
pub contentSizeFlag: ::libc::c_uint,
|
||||
/// < 1: generate a 32-bits checksum at end of frame, for error detection
|
||||
///< 1: generate a 32-bits checksum at end of frame, for error detection
|
||||
pub checksumFlag: ::libc::c_uint,
|
||||
/// < 1: no dictID will be saved into frame header (if dictionary compression)
|
||||
///< 1: no dictID will be saved into frame header (if dictionary compression)
|
||||
pub noDictIDFlag: ::libc::c_uint,
|
||||
}
|
||||
#[test]
|
||||
|
@ -699,9 +713,9 @@ pub enum ZSTD_dictContentType_e {
|
|||
#[repr(u32)]
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum ZSTD_dictLoadMethod_e {
|
||||
/// < Copy dictionary content internally
|
||||
///< Copy dictionary content internally
|
||||
ZSTD_dlm_byCopy = 0,
|
||||
/// < Reference dictionary content -- the dictionary buffer must outlive its users.
|
||||
///< Reference dictionary content -- the dictionary buffer must outlive its users.
|
||||
ZSTD_dlm_byRef = 1,
|
||||
}
|
||||
extern "C" {
|
||||
|
@ -1210,7 +1224,7 @@ extern "C" {
|
|||
extern "C" {
|
||||
/// ZSTD_resetCStream() :
|
||||
/// start a new compression job, using same parameters from previous job.
|
||||
/// This is typically useful to skip dictionary loading stage, since it will re-use it in-place..
|
||||
/// This is typically useful to skip dictionary loading stage, since it will re-use it in-place.
|
||||
/// Note that zcs must be init at least once before using ZSTD_resetCStream().
|
||||
/// If pledgedSrcSize is not known at reset time, use macro ZSTD_CONTENTSIZE_UNKNOWN.
|
||||
/// If pledgedSrcSize > 0, its value must be correct, as it will be written in header, and controlled at the end.
|
||||
|
@ -1228,12 +1242,15 @@ pub struct ZSTD_frameProgression {
|
|||
pub ingested: ::libc::c_ulonglong,
|
||||
pub consumed: ::libc::c_ulonglong,
|
||||
pub produced: ::libc::c_ulonglong,
|
||||
pub flushed: ::libc::c_ulonglong,
|
||||
pub currentJobID: ::libc::c_uint,
|
||||
pub nbActiveWorkers: ::libc::c_uint,
|
||||
}
|
||||
#[test]
|
||||
fn bindgen_test_layout_ZSTD_frameProgression() {
|
||||
assert_eq!(
|
||||
::core::mem::size_of::<ZSTD_frameProgression>(),
|
||||
24usize,
|
||||
40usize,
|
||||
concat!("Size of: ", stringify!(ZSTD_frameProgression))
|
||||
);
|
||||
assert_eq!(
|
||||
|
@ -1280,12 +1297,66 @@ fn bindgen_test_layout_ZSTD_frameProgression() {
|
|||
stringify!(produced)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe {
|
||||
&(*(::core::ptr::null::<ZSTD_frameProgression>())).flushed
|
||||
as *const _ as usize
|
||||
},
|
||||
24usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(ZSTD_frameProgression),
|
||||
"::",
|
||||
stringify!(flushed)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe {
|
||||
&(*(::core::ptr::null::<ZSTD_frameProgression>())).currentJobID
|
||||
as *const _ as usize
|
||||
},
|
||||
32usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(ZSTD_frameProgression),
|
||||
"::",
|
||||
stringify!(currentJobID)
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
unsafe {
|
||||
&(*(::core::ptr::null::<ZSTD_frameProgression>())).nbActiveWorkers
|
||||
as *const _ as usize
|
||||
},
|
||||
36usize,
|
||||
concat!(
|
||||
"Offset of field: ",
|
||||
stringify!(ZSTD_frameProgression),
|
||||
"::",
|
||||
stringify!(nbActiveWorkers)
|
||||
)
|
||||
);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn ZSTD_getFrameProgression(
|
||||
cctx: *const ZSTD_CCtx,
|
||||
) -> ZSTD_frameProgression;
|
||||
}
|
||||
extern "C" {
|
||||
/// ZSTD_toFlushNow() :
|
||||
/// Tell how many bytes are ready to be flushed immediately.
|
||||
/// Useful for multithreading scenarios (nbWorkers >= 1).
|
||||
/// Probe the oldest active job, defined as oldest job not yet entirely flushed,
|
||||
/// and check its output buffer.
|
||||
/// @return : amount of data stored in oldest job and ready to be flushed immediately.
|
||||
/// if @return == 0, it means either :
|
||||
/// + there is no active job (could be checked with ZSTD_frameProgression()), or
|
||||
/// + oldest job is still actively compressing data,
|
||||
/// but everything it has produced has also been flushed so far,
|
||||
/// therefore flushing speed is currently limited by production speed of oldest job
|
||||
/// irrespective of the speed of concurrent newer jobs.
|
||||
pub fn ZSTD_toFlushNow(cctx: *mut ZSTD_CCtx) -> usize;
|
||||
}
|
||||
#[repr(u32)]
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum ZSTD_DStreamParameter_e {
|
||||
|
@ -1315,34 +1386,34 @@ extern "C" {
|
|||
pub fn ZSTD_resetDStream(zds: *mut ZSTD_DStream) -> usize;
|
||||
}
|
||||
extern "C" {
|
||||
/// Buffer-less streaming compression (synchronous mode)
|
||||
///Buffer-less streaming compression (synchronous mode)
|
||||
///
|
||||
/// A ZSTD_CCtx object is required to track streaming operations.
|
||||
/// Use ZSTD_createCCtx() / ZSTD_freeCCtx() to manage resource.
|
||||
/// ZSTD_CCtx object can be re-used multiple times within successive compression operations.
|
||||
///A ZSTD_CCtx object is required to track streaming operations.
|
||||
///Use ZSTD_createCCtx() / ZSTD_freeCCtx() to manage resource.
|
||||
///ZSTD_CCtx object can be re-used multiple times within successive compression operations.
|
||||
///
|
||||
/// Start by initializing a context.
|
||||
/// Use ZSTD_compressBegin(), or ZSTD_compressBegin_usingDict() for dictionary compression,
|
||||
/// or ZSTD_compressBegin_advanced(), for finer parameter control.
|
||||
/// It's also possible to duplicate a reference context which has already been initialized, using ZSTD_copyCCtx()
|
||||
///Start by initializing a context.
|
||||
///Use ZSTD_compressBegin(), or ZSTD_compressBegin_usingDict() for dictionary compression,
|
||||
///or ZSTD_compressBegin_advanced(), for finer parameter control.
|
||||
///It's also possible to duplicate a reference context which has already been initialized, using ZSTD_copyCCtx()
|
||||
///
|
||||
/// Then, consume your input using ZSTD_compressContinue().
|
||||
/// There are some important considerations to keep in mind when using this advanced function :
|
||||
/// - ZSTD_compressContinue() has no internal buffer. It uses externally provided buffers only.
|
||||
/// - Interface is synchronous : input is consumed entirely and produces 1+ compressed blocks.
|
||||
/// - Caller must ensure there is enough space in `dst` to store compressed data under worst case scenario.
|
||||
/// Worst case evaluation is provided by ZSTD_compressBound().
|
||||
/// ZSTD_compressContinue() doesn't guarantee recover after a failed compression.
|
||||
/// - ZSTD_compressContinue() presumes prior input ***is still accessible and unmodified*** (up to maximum distance size, see WindowLog).
|
||||
/// It remembers all previous contiguous blocks, plus one separated memory segment (which can itself consists of multiple contiguous blocks)
|
||||
/// - ZSTD_compressContinue() detects that prior input has been overwritten when `src` buffer overlaps.
|
||||
/// In which case, it will "discard" the relevant memory section from its history.
|
||||
///Then, consume your input using ZSTD_compressContinue().
|
||||
///There are some important considerations to keep in mind when using this advanced function :
|
||||
///- ZSTD_compressContinue() has no internal buffer. It uses externally provided buffers only.
|
||||
///- Interface is synchronous : input is consumed entirely and produces 1+ compressed blocks.
|
||||
///- Caller must ensure there is enough space in `dst` to store compressed data under worst case scenario.
|
||||
///Worst case evaluation is provided by ZSTD_compressBound().
|
||||
///ZSTD_compressContinue() doesn't guarantee recover after a failed compression.
|
||||
///- ZSTD_compressContinue() presumes prior input ***is still accessible and unmodified*** (up to maximum distance size, see WindowLog).
|
||||
///It remembers all previous contiguous blocks, plus one separated memory segment (which can itself consists of multiple contiguous blocks)
|
||||
///- ZSTD_compressContinue() detects that prior input has been overwritten when `src` buffer overlaps.
|
||||
///In which case, it will "discard" the relevant memory section from its history.
|
||||
///
|
||||
/// Finish a frame with ZSTD_compressEnd(), which will write the last block(s) and optional checksum.
|
||||
/// It's possible to use srcSize==0, in which case, it will write a final empty block to end the frame.
|
||||
/// Without last block mark, frames are considered unfinished (hence corrupted) by compliant decoders.
|
||||
///Finish a frame with ZSTD_compressEnd(), which will write the last block(s) and optional checksum.
|
||||
///It's possible to use srcSize==0, in which case, it will write a final empty block to end the frame.
|
||||
///Without last block mark, frames are considered unfinished (hence corrupted) by compliant decoders.
|
||||
///
|
||||
/// `ZSTD_CCtx` object can be re-used (ZSTD_compressBegin()) to compress again.
|
||||
///`ZSTD_CCtx` object can be re-used (ZSTD_compressBegin()) to compress again.
|
||||
pub fn ZSTD_compressBegin(
|
||||
cctx: *mut ZSTD_CCtx,
|
||||
compressionLevel: ::libc::c_int,
|
||||
|
@ -1720,16 +1791,21 @@ extern "C" {
|
|||
extern "C" {
|
||||
/// ZSTD_CCtx_refPrefix() :
|
||||
/// Reference a prefix (single-usage dictionary) for next compression job.
|
||||
/// Decompression need same prefix to properly regenerate data.
|
||||
/// Prefix is **only used once**. Tables are discarded at end of compression job (ZSTD_e_end).
|
||||
/// Decompression will need same prefix to properly regenerate data.
|
||||
/// Compressing with a prefix is similar in outcome as performing a diff and compressing it,
|
||||
/// but performs much faster, especially during decompression (compression speed is tunable with compression level).
|
||||
/// Note that prefix is **only used once**. Tables are discarded at end of compression job (ZSTD_e_end).
|
||||
/// @result : 0, or an error code (which can be tested with ZSTD_isError()).
|
||||
/// Special: Adding any prefix (including NULL) invalidates any previous prefix or dictionary
|
||||
/// Note 1 : Prefix buffer is referenced. It **must** outlive compression job.
|
||||
/// Its contain must remain unmodified up to end of compression (ZSTD_e_end).
|
||||
/// Note 2 : Referencing a prefix involves building tables, which are dependent on compression parameters.
|
||||
/// Note 2 : If the intention is to diff some large src data blob with some prior version of itself,
|
||||
/// ensure that the window size is large enough to contain the entire source.
|
||||
/// See ZSTD_p_windowLog.
|
||||
/// Note 3 : Referencing a prefix involves building tables, which are dependent on compression parameters.
|
||||
/// It's a CPU consuming operation, with non-negligible impact on latency.
|
||||
/// If there is a need to use same prefix multiple times, consider loadDictionary instead.
|
||||
/// Note 3 : By default, the prefix is treated as raw content (ZSTD_dm_rawContent).
|
||||
/// Note 4 : By default, the prefix is treated as raw content (ZSTD_dm_rawContent).
|
||||
/// Use ZSTD_CCtx_refPrefix_advanced() to alter dictMode.
|
||||
pub fn ZSTD_CCtx_refPrefix(
|
||||
cctx: *mut ZSTD_CCtx,
|
||||
|
@ -1950,6 +2026,8 @@ extern "C" {
|
|||
extern "C" {
|
||||
/// ZSTD_DCtx_refPrefix() :
|
||||
/// Reference a prefix (single-usage dictionary) for next compression job.
|
||||
/// This is the reverse operation of ZSTD_CCtx_refPrefix(),
|
||||
/// and must use the same prefix as the one used during compression.
|
||||
/// Prefix is **only used once**. Reference is discarded at end of frame.
|
||||
/// End of frame is reached when ZSTD_DCtx_decompress_generic() returns 0.
|
||||
/// @result : 0, or an error code (which can be tested with ZSTD_isError()).
|
||||
|
@ -2049,6 +2127,28 @@ extern "C" {
|
|||
pub fn ZSTD_DCtx_reset(dctx: *mut ZSTD_DCtx);
|
||||
}
|
||||
extern "C" {
|
||||
///Block functions produce and decode raw zstd blocks, without frame metadata.
|
||||
///Frame metadata cost is typically ~18 bytes, which can be non-negligible for very small blocks (< 100 bytes).
|
||||
///User will have to take in charge required information to regenerate data, such as compressed and content sizes.
|
||||
///
|
||||
///A few rules to respect :
|
||||
///- Compressing and decompressing require a context structure
|
||||
///+ Use ZSTD_createCCtx() and ZSTD_createDCtx()
|
||||
///- It is necessary to init context before starting
|
||||
///+ compression : any ZSTD_compressBegin*() variant, including with dictionary
|
||||
///+ decompression : any ZSTD_decompressBegin*() variant, including with dictionary
|
||||
///+ copyCCtx() and copyDCtx() can be used too
|
||||
///- Block size is limited, it must be <= ZSTD_getBlockSize() <= ZSTD_BLOCKSIZE_MAX == 128 KB
|
||||
///+ If input is larger than a block size, it's necessary to split input data into multiple blocks
|
||||
///+ For inputs larger than a single block size, consider using the regular ZSTD_compress() instead.
|
||||
///Frame metadata is not that costly, and quickly becomes negligible as source size grows larger.
|
||||
///- When a block is considered not compressible enough, ZSTD_compressBlock() result will be zero.
|
||||
///In which case, nothing is produced into `dst`.
|
||||
///+ User must test for such outcome and deal directly with uncompressed data
|
||||
///+ ZSTD_decompressBlock() doesn't accept uncompressed data as input !!!
|
||||
///+ In case of multiple successive blocks, should some of them be uncompressed,
|
||||
///decoder must be informed of their existence in order to follow proper history.
|
||||
///Use ZSTD_insertBlock() for such a case.
|
||||
pub fn ZSTD_getBlockSize(cctx: *const ZSTD_CCtx) -> usize;
|
||||
}
|
||||
extern "C" {
|
||||
|
@ -2079,7 +2179,8 @@ extern "C" {
|
|||
extern "C" {
|
||||
/// ZDICT_trainFromBuffer():
|
||||
/// Train a dictionary from an array of samples.
|
||||
/// Redirect towards ZDICT_optimizeTrainFromBuffer_cover() single-threaded, with d=8 and steps=4.
|
||||
/// Redirect towards ZDICT_optimizeTrainFromBuffer_fastCover() single-threaded, with d=8, steps=4,
|
||||
/// f=20, and accel=1.
|
||||
/// Samples must be stored concatenated in a single flat buffer `samplesBuffer`,
|
||||
/// supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order.
|
||||
/// The resulting dictionary will be saved into `dictBuffer`.
|
||||
|
@ -2237,6 +2338,17 @@ extern "C" {
|
|||
) -> usize;
|
||||
}
|
||||
extern "C" {
|
||||
/// ZSTDMT_toFlushNow()
|
||||
/// Tell how many bytes are ready to be flushed immediately.
|
||||
/// Probe the oldest active job (not yet entirely flushed) and check its output buffer.
|
||||
/// If return 0, it means there is no active job,
|
||||
/// or, it means oldest job is still active, but everything produced has been flushed so far,
|
||||
/// therefore flushing is limited by speed of oldest job.
|
||||
pub fn ZSTDMT_toFlushNow(mtctx: *mut ZSTDMT_CCtx) -> usize;
|
||||
}
|
||||
extern "C" {
|
||||
/// ZSTDMT_CCtxParam_setMTCtxParameter()
|
||||
/// like ZSTDMT_setMTCtxParameter(), but into a ZSTD_CCtx_Params
|
||||
pub fn ZSTDMT_CCtxParam_setMTCtxParameter(
|
||||
params: *mut ZSTD_CCtx_params,
|
||||
parameter: ZSTDMT_parameter,
|
||||
|
@ -2244,6 +2356,9 @@ extern "C" {
|
|||
) -> usize;
|
||||
}
|
||||
extern "C" {
|
||||
/// ZSTDMT_CCtxParam_setNbWorkers()
|
||||
/// Set nbWorkers, and clamp it.
|
||||
/// Also reset jobSize and overlapLog
|
||||
pub fn ZSTDMT_CCtxParam_setNbWorkers(
|
||||
params: *mut ZSTD_CCtx_params,
|
||||
nbWorkers: ::libc::c_uint,
|
||||
|
@ -2259,6 +2374,9 @@ extern "C" {
|
|||
);
|
||||
}
|
||||
extern "C" {
|
||||
/// ZSTDMT_getFrameProgression():
|
||||
/// tells how much data has been consumed (input) and produced (output) for current frame.
|
||||
/// able to count progression inside worker threads.
|
||||
pub fn ZSTDMT_getFrameProgression(
|
||||
mtctx: *mut ZSTDMT_CCtx,
|
||||
) -> ZSTD_frameProgression;
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 90ae50224d15e8dbcb9fa26b9be096366733db8e
|
||||
Subproject commit 4fa456d7f12f8b27bd3b2f5dfd4f46898cb31c24
|
|
@ -5,7 +5,7 @@
|
|||
/* This file is used to generate bindings for both headers.
|
||||
* Just run the following command to generate the bindings:
|
||||
|
||||
bindgen zstd.h --ctypes-prefix ::libc --blacklist-type max_align_t --use-core -o src/bindings.rs -- -DZSTD_STATIC_LINKING_ONLY
|
||||
bindgen zstd.h --ctypes-prefix ::libc --blacklist-type max_align_t --rustified-enum '.*' --use-core -o src/bindings.rs -- -DZSTD_STATIC_LINKING_ONLY
|
||||
|
||||
Or use the `bindgen` feature, which will create the bindings automatically.
|
||||
|
||||
|
|
Loading…
Reference in a new issue