#zstd #zstandard #compression

zstd-safe

Safe low-level bindings for the zstd compression library

23 stable releases

2.0.3+zstd.1.4.4 Nov 5, 2019
1.4.13+zstd.1.4.3 Aug 20, 2019
1.4.12+zstd.1.4.2 Jul 25, 2019
1.4.7+zstd.1.3.8 Dec 27, 2018
1.3.1 Jul 5, 2017

#13 in Compression

Download history 1932/week @ 2019-07-23 3292/week @ 2019-07-30 2554/week @ 2019-08-06 2011/week @ 2019-08-13 2211/week @ 2019-08-20 2369/week @ 2019-08-27 1931/week @ 2019-09-03 3170/week @ 2019-09-10 2438/week @ 2019-09-17 3967/week @ 2019-09-24 3197/week @ 2019-10-01 3593/week @ 2019-10-08 3324/week @ 2019-10-15 5161/week @ 2019-10-22 4916/week @ 2019-10-29

13,644 downloads per month
Used in 57 crates (2 directly)

MIT/Apache

5MB
97K SLoC

C 74K SLoC // 0.2% comments Rust 9K SLoC // 0.1% comments Visual Studio Project 6K SLoC C++ 3K SLoC // 0.1% comments Shell 2.5K SLoC // 0.3% comments Python 1.5K SLoC // 0.1% comments Visual Studio Solution 223 SLoC Batch 113 SLoC Lua 68 SLoC // 0.0% comments

zstd-safe

This is a thin, no-std, safe abstraction built on top of the bindings from [zstd-sys].

It is close to a 1-for-1 mapping to the C functions, but uses rust types like slices instead of pointers and lengths.

For a more comfortable higher-level library (with Read/Write implementations), see zstd-rs.


lib.rs:

Minimal safe wrapper around zstd-sys.

This crates provides a minimal translation of the zstd-sys methods. For a more comfortable high-level library, see the zstd crate.

Introduction

zstd, short for Zstandard, is a fast lossless compression algorithm, targeting real-time compression scenarios at zlib-level and better compression ratios. The zstd compression library provides in-memory compression and decompression functions. The library supports compression levels from 1 up to ZSTD_maxCLevel() which is 22. Levels >= 20, labeled --ultra, should be used with caution, as they require more memory.

Compression can be done in:

  • a single step (described as Simple API)
  • a single step, reusing a context (described as Explicit memory management)
  • unbounded multiple steps (described as Streaming compression)

The compression ratio achievable on small data can be highly improved using compression with a dictionary in:

  • a single step (described as Simple dictionary API)
  • a single step, reusing a dictionary (described as Fast dictionary API)

Advanced experimental functions can be accessed using #define ZSTD_STATIC_LINKING_ONLY before including zstd.h. These APIs shall never be used with a dynamic library. They are not "stable", their definition may change in the future. Only static linking is allowed.

Dependencies