lz4rip 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/Cargo.lock +3 -39
- data/README.md +12 -34
- data/ext/lz4rip/Cargo.toml +2 -2
- data/ext/lz4rip/build.rs +23 -0
- data/ext/lz4rip/src/lib.rs +530 -208
- data/ext/lz4rip/src/rb.rs +628 -0
- data/lib/lz4rip/block_codec.rb +39 -0
- data/lib/lz4rip/dict_trainer.rb +32 -0
- data/lib/lz4rip/dictionary.rb +10 -0
- data/lib/lz4rip/frame_codec.rb +46 -0
- data/lib/lz4rip/version.rb +1 -1
- data/lib/lz4rip.rb +17 -0
- metadata +6 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2f66c12c967a06a207c9e8e742fac306280863bf655bd7b4318a2265d08c1cdf
|
|
4
|
+
data.tar.gz: be95ea7eb336509e7077737f0d4703dc500931f1608fdc2f52dc3b170904b16d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2fc02b8f797989ca99f23e97658dab9442c4fbb70ab03ff3436a73b5026b78d20c1bbf240e4febba0baed905863b225655f03c627d6db4ddee128224b419c82c
|
|
7
|
+
data.tar.gz: 92b2aa66f6282317c5b805f77cf47715288c8debc013520e5dffc78fb7d9c102f62f330906042b062b93aa2104ca21c5b1b0830edd87852b585f6451f4146efd
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.2.0] - 2026-08-07
|
|
6
|
+
|
|
7
|
+
- Release the Ruby GVL around large frame/block compression and frame
|
|
8
|
+
decompression calls.
|
|
9
|
+
- Update the `lz4rip` crate dependency to 0.11.3.
|
|
10
|
+
- Replace Magnus with direct `rb-sys` bindings, add TruffleRuby build support,
|
|
11
|
+
and lower the Ruby requirement to 3.4.
|
|
12
|
+
- Add `max_decompressed_size:` to `Lz4rip::FrameCodec#decompress`, with the
|
|
13
|
+
cap enforced across concatenated frame output.
|
|
14
|
+
- Add RubyDoc metadata and move API reference details from `README.md` into
|
|
15
|
+
YARD comments.
|
|
16
|
+
|
|
5
17
|
## [0.1.2] - 2026-08-05
|
|
6
18
|
|
|
7
19
|
- Update `lz4rip` crate dependency from 0.11.1 to 0.11.2.
|
data/Cargo.lock
CHANGED
|
@@ -108,16 +108,15 @@ dependencies = [
|
|
|
108
108
|
name = "lz4rip"
|
|
109
109
|
version = "0.1.2"
|
|
110
110
|
dependencies = [
|
|
111
|
-
"lz4rip 0.11.
|
|
112
|
-
"magnus",
|
|
111
|
+
"lz4rip 0.11.3",
|
|
113
112
|
"rb-sys",
|
|
114
113
|
]
|
|
115
114
|
|
|
116
115
|
[[package]]
|
|
117
116
|
name = "lz4rip"
|
|
118
|
-
version = "0.11.
|
|
117
|
+
version = "0.11.3"
|
|
119
118
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
120
|
-
checksum = "
|
|
119
|
+
checksum = "55bde261679fd1d14bcae126094d7afb98c63c1a5018d0718741b658b686e950"
|
|
121
120
|
dependencies = [
|
|
122
121
|
"lz4rip-core",
|
|
123
122
|
"lz4rip-decode",
|
|
@@ -149,29 +148,6 @@ dependencies = [
|
|
|
149
148
|
"lz4rip-core",
|
|
150
149
|
]
|
|
151
150
|
|
|
152
|
-
[[package]]
|
|
153
|
-
name = "magnus"
|
|
154
|
-
version = "0.8.2"
|
|
155
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
156
|
-
checksum = "3b36a5b126bbe97eb0d02d07acfeb327036c6319fd816139a49824a83b7f9012"
|
|
157
|
-
dependencies = [
|
|
158
|
-
"magnus-macros",
|
|
159
|
-
"rb-sys",
|
|
160
|
-
"rb-sys-env",
|
|
161
|
-
"seq-macro",
|
|
162
|
-
]
|
|
163
|
-
|
|
164
|
-
[[package]]
|
|
165
|
-
name = "magnus-macros"
|
|
166
|
-
version = "0.8.0"
|
|
167
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
168
|
-
checksum = "47607461fd8e1513cb4f2076c197d8092d921a1ea75bd08af97398f593751892"
|
|
169
|
-
dependencies = [
|
|
170
|
-
"proc-macro2",
|
|
171
|
-
"quote",
|
|
172
|
-
"syn",
|
|
173
|
-
]
|
|
174
|
-
|
|
175
151
|
[[package]]
|
|
176
152
|
name = "memchr"
|
|
177
153
|
version = "2.8.3"
|
|
@@ -236,12 +212,6 @@ dependencies = [
|
|
|
236
212
|
"syn",
|
|
237
213
|
]
|
|
238
214
|
|
|
239
|
-
[[package]]
|
|
240
|
-
name = "rb-sys-env"
|
|
241
|
-
version = "0.2.3"
|
|
242
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
243
|
-
checksum = "cca7ad6a7e21e72151d56fe2495a259b5670e204c3adac41ee7ef676ea08117a"
|
|
244
|
-
|
|
245
215
|
[[package]]
|
|
246
216
|
name = "regex"
|
|
247
217
|
version = "1.13.1"
|
|
@@ -277,12 +247,6 @@ version = "2.1.3"
|
|
|
277
247
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
278
248
|
checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d"
|
|
279
249
|
|
|
280
|
-
[[package]]
|
|
281
|
-
name = "seq-macro"
|
|
282
|
-
version = "0.3.6"
|
|
283
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
284
|
-
checksum = "1bc711410fbe7399f390ca1c3b60ad0f53f80e95c5eb935e52268a0e2cd49acc"
|
|
285
|
-
|
|
286
250
|
[[package]]
|
|
287
251
|
name = "shell-words"
|
|
288
252
|
version = "1.1.1"
|
data/README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
# lz4rip
|
|
1
|
+
# lz4rip: Ractor-safe LZ4 for Ruby
|
|
2
2
|
|
|
3
3
|
[](https://github.com/paddor/lz4rip-rb/actions/workflows/ci.yml)
|
|
4
4
|
[](https://rubygems.org/gems/lz4rip)
|
|
5
5
|
[](LICENSE)
|
|
6
|
-
[](https://www.ruby-lang.org)
|
|
7
7
|
|
|
8
8
|
Ruby bindings for [lz4rip](https://crates.io/crates/lz4rip), a pure-Rust LZ4
|
|
9
|
-
implementation. Built
|
|
10
|
-
|
|
9
|
+
implementation. Built as an `rb-sys` native extension and declared Ractor-safe
|
|
10
|
+
so you can compress from any Ractor without a global lock.
|
|
11
11
|
|
|
12
12
|
## Features
|
|
13
13
|
|
|
@@ -20,7 +20,7 @@ declared Ractor-safe so you can compress from any Ractor without a global lock.
|
|
|
20
20
|
|
|
21
21
|
## Install
|
|
22
22
|
|
|
23
|
-
Requires Ruby >= 4
|
|
23
|
+
Requires Ruby >= 3.4 and a Rust toolchain (for building the native extension):
|
|
24
24
|
|
|
25
25
|
```sh
|
|
26
26
|
gem install lz4rip
|
|
@@ -42,6 +42,7 @@ require "lz4rip"
|
|
|
42
42
|
codec = Lz4rip::FrameCodec.new
|
|
43
43
|
compressed = codec.compress("hello world " * 1000)
|
|
44
44
|
original = codec.decompress(compressed)
|
|
45
|
+
bounded = codec.decompress(compressed, max_decompressed_size: 12_000)
|
|
45
46
|
```
|
|
46
47
|
|
|
47
48
|
### Block codec (raw LZ4 blocks)
|
|
@@ -78,6 +79,9 @@ codec = Lz4rip::BlockCodec.new(dict: dict)
|
|
|
78
79
|
|
|
79
80
|
### Ractor safety
|
|
80
81
|
|
|
82
|
+
On Ruby VMs without Ractor support, the codecs still work normally; the
|
|
83
|
+
Ractor-specific guarantees and examples do not apply.
|
|
84
|
+
|
|
81
85
|
```ruby
|
|
82
86
|
codec = Lz4rip::FrameCodec.new
|
|
83
87
|
|
|
@@ -93,35 +97,9 @@ end
|
|
|
93
97
|
ractors.each { |r| p r.value } # => :ok, :ok, :ok, :ok
|
|
94
98
|
```
|
|
95
99
|
|
|
96
|
-
##
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|---|---|---|
|
|
100
|
-
| `Lz4rip::FrameCodec` | `.new(dict: nil)` | Create a frame codec, optionally with a `Dictionary` or raw `String` dict |
|
|
101
|
-
| | `#compress(string)` | Compress to LZ4 frame |
|
|
102
|
-
| | `#decompress(string)` | Decompress an LZ4 frame |
|
|
103
|
-
| | `#has_dict?` | Whether a dictionary is loaded |
|
|
104
|
-
| | `#id` | Dictionary ID (nil without dict) |
|
|
105
|
-
| | `#size` | Dictionary size in bytes (0 without dict) |
|
|
106
|
-
| `Lz4rip::BlockCodec` | `.new(dict: nil)` | Create a block codec, optionally with a dict `String` |
|
|
107
|
-
| | `#compress(string)` | Compress to raw LZ4 block |
|
|
108
|
-
| | `#decompress(string, decompressed_size:)` | Decompress a raw LZ4 block |
|
|
109
|
-
| | `#has_dict?` | Whether a dictionary is loaded |
|
|
110
|
-
| | `#size` | Internal state size in bytes |
|
|
111
|
-
| `Lz4rip::Dictionary` | `.new(bytes:, id: auto)` | Immutable dictionary value object |
|
|
112
|
-
| | `#bytes` | Frozen binary dict bytes |
|
|
113
|
-
| | `#id` | 32-bit dictionary ID |
|
|
114
|
-
| | `#size` | Dictionary size in bytes |
|
|
115
|
-
| `Lz4rip::DictTrainer` | `.new(max_dict_size)` | Create a trainer (capped at 65535) |
|
|
116
|
-
| | `#add_sample(string)` | Feed a training sample |
|
|
117
|
-
| | `#train` | Consume the trainer, return dict bytes |
|
|
118
|
-
| | `#sample_count` | Number of accepted samples |
|
|
119
|
-
| | `#total_bytes` | Total bytes of accepted samples |
|
|
120
|
-
| | `#trained?` | Whether `#train` has been called |
|
|
121
|
-
| | `#max_dict_size` | Configured max dict size |
|
|
122
|
-
| `Lz4rip` | `.compress_bound(size)` | Max compressed output size for a given input size |
|
|
123
|
-
| | `.block_stream_size` | Internal compressor heap size |
|
|
124
|
-
| `Lz4rip::DecompressError` | | Raised on decompression failure (subclass of `StandardError`) |
|
|
100
|
+
## Documentation
|
|
101
|
+
|
|
102
|
+
Reference: <https://rubydoc.info/gems/lz4rip>
|
|
125
103
|
|
|
126
104
|
## License
|
|
127
105
|
|
data/ext/lz4rip/Cargo.toml
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
name = "lz4rip"
|
|
3
3
|
version = "0.1.2"
|
|
4
4
|
edition = "2021"
|
|
5
|
+
build = "build.rs"
|
|
5
6
|
|
|
6
7
|
[lib]
|
|
7
8
|
name = "lz4rip"
|
|
8
9
|
crate-type = ["cdylib", "rlib"]
|
|
9
10
|
|
|
10
11
|
[dependencies]
|
|
11
|
-
lz4 = { version = "0.11.
|
|
12
|
-
magnus = "0.8"
|
|
12
|
+
lz4 = { version = "0.11.3", package = "lz4rip" }
|
|
13
13
|
rb-sys = "0.9"
|
|
14
14
|
|
|
15
15
|
[build-dependencies]
|
data/ext/lz4rip/build.rs
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
use std::process::Command;
|
|
2
|
+
|
|
3
|
+
fn main() {
|
|
4
|
+
println!("cargo:rerun-if-env-changed=RUBY");
|
|
5
|
+
println!("cargo:rustc-check-cfg=cfg(ruby_engine, values(\"mri\", \"truffleruby\"))");
|
|
6
|
+
|
|
7
|
+
let ruby = std::env::var("RUBY").unwrap_or_else(|_| "ruby".to_string());
|
|
8
|
+
let output = Command::new(&ruby)
|
|
9
|
+
.arg("-rrbconfig")
|
|
10
|
+
.arg("-e")
|
|
11
|
+
.arg("print RbConfig::CONFIG.fetch('ruby_install_name')")
|
|
12
|
+
.output()
|
|
13
|
+
.unwrap_or_else(|err| panic!("failed to run {ruby}: {err}"));
|
|
14
|
+
|
|
15
|
+
if !output.status.success() {
|
|
16
|
+
panic!("failed to query Ruby engine with {ruby}");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
match String::from_utf8_lossy(&output.stdout).trim() {
|
|
20
|
+
"truffleruby" => println!("cargo:rustc-cfg=ruby_engine=\"truffleruby\""),
|
|
21
|
+
_ => println!("cargo:rustc-cfg=ruby_engine=\"mri\""),
|
|
22
|
+
}
|
|
23
|
+
}
|