libz-rs-sys

A zlib implementation in rust available as a C dynamic library and as a rust crate

Latest version: 0.6.3 registry icon
Maintenance score
100
Safety score
99
Popularity score
79
Check your open source dependency risks. Get immediate insight about security, stability and licensing risks.
Security
  Vulnerabilities
Version Suggest Low Medium High Critical
0.6.3 0 0 0 0 0
0.6.2 0 0 0 0 0
0.6.1 0 0 0 0 0
0.6.0 0 0 0 0 0
0.5.5 0 0 0 0 0
0.5.4 0 0 0 0 0
0.5.3 0 0 0 0 0
0.5.2 0 0 0 0 0
0.5.1 0 0 0 0 0
0.5.0 0 0 0 0 0
0.4.2 0 0 0 0 0
0.4.1 0 0 0 0 0
0.4.0 0 0 0 0 0
0.3.1 0 0 1 0 0
0.3.0 0 0 1 0 0
0.2.1 0 0 1 0 0
0.2.0 0 0 1 0 0
0.1.1 0 0 1 0 0
0.1.0 0 0 1 0 0
0.0.1 0 0 1 0 0

Stability
Latest release:

0.6.3 - This version is safe to use because it has no known security vulnerabilities at this time. Find out if your coding project uses this component and get notified of any reported security vulnerabilities with Meterian-X Open Source Security Platform

Licensing

Maintain your licence declarations and avoid unwanted licences to protect your IP the way you intended.

Zlib   -   zlib License

Not a wildcard

Not proprietary

OSI Compliant



checks codecov Crates.io

zlib-rs: a safer zlib

This repository contains a Rust implementation of the zlib file format that is compatible with the zlib API.

This repository contains two public crates:

  • zlib-rs, a Rust implementation based on zlib with a safe rust API. This API is under development and still unstable.
  • libz-rs-sys, a zlib-compatible C API for usage in non-Rust applications.

How to use zlib-rs in your project

zlib-rs can be used in both Rust and C projects.

Rust projects

By far the easiest way to use zlib-rs is through the flate2 crate, by simply enabling the zlib-rs feature gate. This will enable the zlib-rs backend.

C projects

zlib-rs can be built as a shared object file for usage by C programs that dynamically link to zlib. Please see the example in libz-rs-sys-cdylib.

Performance

Performance is generally on-par with zlib-ng.

Compiler Flags

Compiler flags that can be used to improve performance.

-Ctarget-cpu=...

Providing more information about the SIMD capabilities of the target machine can improve performance. E.g.

RUSTFLAGS="-Ctarget-cpu=native" cargo build --release ...

The resulting binary statically assumes the SIMD capabilities of the current machine.

Note: binaries built with -Ctarget-cpu almost certainly crash on systems that don't have the specified CPU! Only use this flag if you control how the binary is deployed, and can guarantee that the CPU assumptions are never violated.

-Cllvm-args=-enable-dfa-jump-thread

For best performance with very small input sizes, compile with:

RUSTFLAGS="-Cllvm-args=-enable-dfa-jump-thread" cargo build --release ...

This flag gives around a 10% boost when the input arrives in chunks of 16 bytes, and a couple percent when input arrives in chunks of under 1024 bytes. Beyond that, the effect is not significant. Using this flag can lead to longer compile times, but otherwise has no adverse effects.

Acknowledgments

This project is heavily based on the zlib and zlib-ng projects.

About

zlib-rs is part of Trifecta Tech Foundation's Data compression initiative.

History

The initial development of zlib-rs was started and funded by the Internet Security Research Group as part of the Prossimo project.