https://github.com/dearblue/mruby-zstd
mruby bindings for zstd
https://github.com/dearblue/mruby-zstd
compressions mruby zstd
Last synced: about 1 month ago
JSON representation
mruby bindings for zstd
- Host: GitHub
- URL: https://github.com/dearblue/mruby-zstd
- Owner: dearblue
- License: bsd-2-clause
- Created: 2017-07-11T13:25:07.000Z (almost 8 years ago)
- Default Branch: wip
- Last Pushed: 2021-02-03T14:55:03.000Z (over 4 years ago)
- Last Synced: 2025-02-12T11:34:39.457Z (3 months ago)
- Topics: compressions, mruby, zstd
- Language: C
- Size: 40 KB
- Stars: 2
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mruby-zstd : mruby bindings for zstd the compression library (unofficial)
## HOW TO INSTALL
`build_config.rb` に `gem mgem: "mruby-zstd"` を追加して下さい。
```ruby
MRuby::Build.new do |conf|
gem mgem: "mruby-zstd"
end
```## HOW TO USAGE
### 圧縮
```ruby
src = "123456789"
dest = Zstd.encode(src)
```圧縮レベルを指定したい場合:
```ruby
src = "123456789"
complevel = 15 # 1..22 の範囲で与える。既定値は nil で、1 と等価
dest = Zstd.encode(src, level: complevel)
```### 伸長
```ruby
zstdseq = ... # zstd'd string by Zstd.encode
# OR .zst file data by zstd-cli
dest = Zstd.decode(zstdseq)
```### ストリーミング圧縮
```ruby
output = AnyObject.new # An object that has ``.<<'' method (e.g. IO, StringIO, or etc.)
Zstd.encode(output) do |zstd|
zstd << "abcdefg"
zstd << "123456789" * 99
end
```### ストリーミング伸長
```ruby
input = AnyObject.new # An object that has ``.read'' method (e.g. IO, StringIO, or etc.)
Zstd.decode(input) do |zstd|
zstd.read(20)
buf = ""
zstd.read(5, buf)
zstd.read(10, buf)
zstd.read(nil, buf)
end
```## build_config.rb
### ``ZSTD_LEGACY_SUPPORT``
``build_config.rb`` で ``ZSTD_LEGACY_SUPPORT`` を定義することによって、zstd-1.0 以前のデータ形式を伸長できるようになります。
```ruby:build_config.rb
MRuby::Build.new("host") do |conf|
conf.cc.defines << "ZSTD_LEGACY_SUPPORT"...
end
```### ``MRUBY_ZSTD_DEFAULT_PARTIAL_SIZE``
``build_config.rb`` で ``MRUBY_ZSTD_DEFAULT_PARTIAL_SIZE`` を定義することによって、段階的なメモリ拡張サイズを指定することが出来ます。
```ruby:build_config.rb
MRuby::Build.new("host") do |conf|
conf.cc.defines << "MRUBY_ZSTD_DEFAULT_PARTIAL_SIZE=65536"...
end
```既定値は、MRB_INT_16 が定義された場合は 4 KiB、それ以外の場合は 1 MiB となっています。
## Specification
- Product name: [mruby-zstd](https://github.com/dearblue/mruby-zstd)
- Version: 0.2.4
- Product quality: PROTOTYPE
- Author: [dearblue](https://github.com/dearblue)
- Report issue to:
- Licensing: [2 clause BSD License](LICENSE)
- Dependency external mrbgems: (NONE)
- Bundled C libraries (git-submodule'd):
- [zstd](https://github.com/facebook/zstd)
[version 1.4.8](https://github.com/facebook/zstd/tree/v1.4.8)
under [3 clause BSD License](https://github.com/facebook/zstd/blob/v1.4.8/LICENSE)
by [Facebook](https://github.com/facebook)