Shard Detail

zstd v1.0.0

Crystal bindings to the Zstandard (zstd) compression library
crystal crystal-bindings zstd zstandard compression-library

Install & Use

Add the following code to your project's shard.yml under:

dependencies to use in production
- OR -
development_dependencies to use in development


zstd:
  github: didactic-drunk/zstd.cr
  version: 1.0.0

Readme

zstd

Build Status GitHub release Docs

Crystal bindings to the Zstandard (zstd) compression library

Features

  • Performance optimized. 20M small decompression messages/sec.
  • All API calls allow reusable buffers to reduce GC overhead.
  • No heap allocations after #initialize.
  • Crystal IO compatible Streaming API.
  • Snappy like buffer API for handling small messages.
  • export ZSTD_CLEVEL=1 sets the default compression level just like the zstd command line utilities.
  • Only require what you need for faster compilation. (require "zstd/compress/context")

Todo

  • Auto install the most recent zstd if the system library is old or unavailable.
  • Custom dictionaries
  • Support more zstd params.
  • More specs.

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      zstd:
        github: didactic-drunk/zstd.cr
    
  2. Run shards install

Usage

require "zstd"

Buffer API

cctx = Zstd::Compress::Context.new(level: 1)
cbuf = cctx.compress buf

dctx = Zstd::Decompress::Context.new
dbuf = dctx.decompress cbuf

Streaming API

buf = Bytes.new 5
mio = IO::Memory.new
Zstd::Compress::IO.open(mio, level: 1) do |cio|
  cio.write buf
end

mio.rewind
str = Zstd::Decompress::IO.open(mio) do |dio|
  dio.gets_to_end
end

Development

TODO: Write development instructions here

Contributing

  1. Fork it (https://github.com/your-github-user/zstd/fork)
  2. Install a formatting check git hook (ln -sf ../../scripts/git/pre-commit .git/hooks)
  3. Create your feature branch (git checkout -b my-new-feature)
  4. Commit your changes (git commit -am 'Add some feature')
  5. Push to the branch (git push origin my-new-feature)
  6. Create a new Pull Request

Contributors