All Projects → wltsmrz → nim_zstd

wltsmrz / nim_zstd

Licence: MIT license
Nim bindings for zstd

Programming Languages

c
50402 projects - #5 most used programming language
C++
36643 projects - #6 most used programming language
shell
77523 projects
HTML
75241 projects
Makefile
30231 projects
python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to nim zstd

Squashfs Tools Ng
A new set of tools and libraries for working with SquashFS images
Stars: ✭ 76 (+171.43%)
Mutual labels:  zstd
Python Zstandard
Python bindings to the Zstandard (zstd) compression library
Stars: ✭ 233 (+732.14%)
Mutual labels:  zstd
ZstdKit
An Objective-C and Swift library for Zstd (Zstandard) compression and decompression.
Stars: ✭ 22 (-21.43%)
Mutual labels:  zstd
Libarchive
Multi-format archive and compression library
Stars: ✭ 1,625 (+5703.57%)
Mutual labels:  zstd
Turbobench
Compression Benchmark
Stars: ✭ 211 (+653.57%)
Mutual labels:  zstd
7-Zip-Filetype-Theme
7-Zip Filetype Theme Windows 10 and Windows 11
Stars: ✭ 145 (+417.86%)
Mutual labels:  zstd
Hs Zstd
Bindings to the Zstandard library to make it usable from the Haskell programming language.
Stars: ✭ 45 (+60.71%)
Mutual labels:  zstd
pyzstd
Python bindings to Zstandard (zstd) compression library, the API is similar to Python's bz2/lzma/zlib modules.
Stars: ✭ 4 (-85.71%)
Mutual labels:  zstd
P7zip
A new p7zip fork with additional codecs and improvements (forked from https://sourceforge.net/projects/p7zip/).
Stars: ✭ 222 (+692.86%)
Mutual labels:  zstd
sparkzstd
A zstd decompressor written in golang
Stars: ✭ 45 (+60.71%)
Mutual labels:  zstd
7 Zip Zstd
7-Zip with support for Brotli, Fast-LZMA2, Lizard, LZ4, LZ5 and Zstandard
Stars: ✭ 2,150 (+7578.57%)
Mutual labels:  zstd
Zstdnet
Zstd wrapper for .NET
Stars: ✭ 176 (+528.57%)
Mutual labels:  zstd
ZRA
ZStandard Random Access (ZRA) allows random access inside an archive compressed using ZStandard
Stars: ✭ 21 (-25%)
Mutual labels:  zstd
Zstd
Zstandard implementation in Wuffs
Stars: ✭ 107 (+282.14%)
Mutual labels:  zstd
zstd-rs
zstd-decoder in pure rust
Stars: ✭ 148 (+428.57%)
Mutual labels:  zstd
Zstd Nginx Module
Nginx modules for the Zstandard compression
Stars: ✭ 64 (+128.57%)
Mutual labels:  zstd
pgzstd
Postgres module for Zstandard compression/decompression with preset dictionary support
Stars: ✭ 31 (+10.71%)
Mutual labels:  zstd
wget-lua
Wget-AT is a modern Wget with Lua hooks, Zstandard (+dictionary) WARC compression and URL-agnostic deduplication.
Stars: ✭ 52 (+85.71%)
Mutual labels:  zstd
zstd-ruby
Ruby binding for zstd(Zstandard - Fast real-time compression algorithm)
Stars: ✭ 45 (+60.71%)
Mutual labels:  zstd
zstdlite
Fast, configurable in-memory compression of R objects with zstd
Stars: ✭ 19 (-32.14%)
Mutual labels:  zstd

zstd

Nim bindings for zstd

$ nimble install zstd

Simple API

  import zstd/compress
  import zstd/decompress

  var source = readFile("tests/files/nixon.bmp")
  var compressed = compress(source, level=3)
  var decompressed = decompress(compressed)
  check equalmem(decompressed[0].addr, source[0].addr, source.len)

Advanced API

Uses a ZSTD context for setting options, using for multiple calls, etc.

When compressing many times, it is recommended to allocate a context just once, and re-use it for each successive compression operation. This will make workload friendlier for system's memory. Note : re-using context is just a speed / resource optimization. It doesn't change the compression ratio, which remains identical. Note 2 : In multi-threaded environments, use one different context per thread for parallel execution.

  import zstd/compress
  import zstd/decompress

  var source = readFile("tests/files/nixon.bmp")

  var cctx = new_compress_context()
  var compressed = compress(cctx, source, level=3)
  discard free_context(cctx)

  var dctx = new_decompress_context()
  var decompressed = decompress(dctx, compressed)
  discard free_context(dctx)

  check equalmem(decompressed[0].addr, source[0].addr, source.len)

With dictionary

  import zstd/common # for bytes()
  import zstd/compress
  import zstd/decompress

  var source = bytes(readFile("tests/files/nixon.bmp"))
  var dict = bytes(readFile("tests/files/nixon.dict"))

  var cctx = new_compress_context()
  var compressed = compress(cctx, source, dict, level=3)
  discard free_context(cctx)

  var dctx = new_decompress_context()
  var decompressed = decompress(dctx, compressed, dict)
  discard free_context(dctx)

  check equalmem(decompressed[0].addr, source[0].addr, source.len)

Streaming

  var c_in_stream = newFileStream("tests/files/nixon.bmp", fmRead)
  var c_out_stream = newFileStream("tests/files/nixon-copy.bmp.zst", fmWrite)

  # compress nixon.bmp to nixon-copy.bmp.zst with level 3
  compress(c_in_stream, c_out_stream, level=3)

  var d_in_stream = newFileStream("tests/files/nixon-copy.bmp.zst", fmRead)
  var d_out_stream = newFileStream("tests/files/nixon-copy.bmp", fmWrite)

  # decompress nixon-copy.bmp.zst to nixon-copy.bmp
  decompress(d_in_stream, d_out_stream)

  var original = bytes(readFile("tests/files/nixon.bmp"))
  var cycled = bytes(readFile("tests/files/nixon-copy.bmp"))

  check equalmem(cycled[0].addr, original[0].addr, original.len)

Compile flags

-d:useExternalZstd to skip compiling with zstd and use system zstd instead (not default behavior)

-d:zstdPath=/home/zstd specify path to custom zstd

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].