
Security News
Package Maintainers Call for Improvements to GitHub’s New npm Security Plan
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
zstdlib is native Ruby extension for Zstandard data compression library.
zstdlib is currently available for the MRI Ruby platform.
Unlike the other Zstd bindings available for Ruby, Zstdlib utilizes Zstd's native Zlib compatibility layer.
This specifically means that Zstdlib
module is and will be (mostly) API-compatible with standard Ruby Zlib
module and thus zstdlib can be used as a drop-in replacement for zlib: just replace Zlib
with Zstdlib
throughout the source code and you're in!
Streams produced by Zstdlib::Deflate
class can be decompressed with standard zstd utility and hence can be written to .zst or .zstd files.
Conversely, the Zstdlib::Inflate
class can handle data from such files.
require 'zstdlib'
data = Zstdlib.deflate('Hello Zstd')
require 'zstdlib'
zstd = Zstdlib::Deflate.new
data = String.new
data << zstd.deflate('Hello')
data << zstd.deflate('Zstd')
data << zstd.finish
require 'zstdlib'
data = Zstdlib.inflate(compressed_data)
zstdlib covers the following parts of zlib:
ZStream
, Inflate
and Deflate
classesZlib::
constants (DEFAULT_COMPRESSION
etc.)Zlib::
exception classes (Error
and its descendants)Note that zstdlib currently omits Gzip file support with its GzipFile
, GzipReader
and GzipWriter
classes
and associated constants although this may be changed in future.
There exist Zstdlib::ZSTD_VERSION
constant and Zstdlib.zstd_version
module method which can be used to obtain shipped Zstd library version.
In order to enable Zstd (de)compression capability in existing code, simply replace zlib with zstdlib in require statements and
Zlib
with Zstdlib
module references throughout the code.
The rest of the zlib-aware code should work unchanged.
For further information refer to documentation on zlib .
If unsure do not pass anything to constructor in order to use DEFAULT_COMPRESSION
level which works for both zlib ans zstdlib.
Contrary to zlib the NO_COMPRESSION
constant in zstdlib is an equivalent to BEST_SPEED
as Zstd always compresses data.
The BEST_COMPRESSION
constant is adjusted to reflect Zstd-specific compression level range.
Anyways this level is recommended against due to abysmal performance not to be expected from the fast state-of-the-art compression algorithm.
The Zstd documentation (currently) recommends using 19 as the level for optimal best compression.
The BEST_SPEED
constant remains unchanged.
zstdlib home page on GitHub.
Source code and system-specific compiled gems can be obtained from rubygems.org.
The system-specific gems are currently provided for x32/x64 Windows and x64/ARM64 MacOS platforms.
Note that these gems are built with the rake-compiler-dock infrastructure the minimum supported Ruby version is raised to 2.4. All other installations including Linux will use the source gem and hence require the compilation step with locally installed development tools.
For user-visible changes refer to change log.
This module is in testing phase so things beyond basic interface might not work as expected.
Documentation extracted from zstdlib still contains traces of old zlib-related pieces. Just keep this in mind and substitute zlib with zstdlib upon browsing.
Gzip .gz file support, although available in Zstd's Zlib compatibility layer, is currently disabled.
Zstd's external compression dictionaries capability is not (yet) implemented.
Cheers,
Oleg A. Khlybov <fougas@mail.ru>
FAQs
Unknown package
We found that zstdlib demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.