lz4rip 0.1.2 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 57c8a45c7f389dd4f6b324e147fcbf7cbfec93ca2746226120ea3290741ba761
4
- data.tar.gz: b651348f2fce6405b8dabdb7208359eebdd28565a44bf9948a1ca4dcc1317e62
3
+ metadata.gz: ca8b2f012551b63cf5efaaee91d49b319486300a9bb1e22f0d79d64d868ba076
4
+ data.tar.gz: ff7f8c704a56fa29e80ade1d046f3e7fb93eac22bca44d8b684a4727db69355d
5
5
  SHA512:
6
- metadata.gz: 170650658b63413bd2b03659b168a9f77b5e434db3a8cbca52a7155282e5b7f7b0e16123e6ccbcb4aa48e15cc13d17993f902477a501cb80100b3f3375b14add
7
- data.tar.gz: f8b9b5c1fa3f9fdc043af195137999f8d301ae2b4b984a4cc780f190dbc49dad21256fbf5a056804b86f5fea56c0c3fc7e97602ae384765bcb35afd88bb91f28
6
+ metadata.gz: 689b55762fed92109d07f280cc1d534e3f4e71ba76c63c1a6c149441ded0ae08d21e4d134a7000f1b4fb40941e7768856113e82272ce88e359bfedcc1b97e3ff
7
+ data.tar.gz: 7f0a1a29b634874f60bde320df035aa14e6cd0080758a3dbd7e3147a74e88e3c1327ee77d1cf383448f591c6162d76e6355637286eed3ee74958e0315eb3d3fc
data/CHANGELOG.md CHANGED
@@ -2,6 +2,35 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.2.1] - 2026-10-11
6
+
7
+ - Update the `lz4rip` crate dependency to 0.11.10 and `rb-sys` to 0.9.130.
8
+ - Make `FrameCodec` instances Ractor-shareable as documented, with native
9
+ dictionary copies that leave caller strings mutable.
10
+ - Unlock input strings and free native results when Ruby interrupts a call
11
+ that released the GVL.
12
+ - Protect mutable inputs when mutex contention releases the GVL, including
13
+ calls below the normal size threshold.
14
+ - Catch Rust panics inside native callbacks instead of aborting the process.
15
+ - Preserve Ruby exceptions, `Thread#kill`, and `catch`/`throw` through
16
+ protected native calls.
17
+ - Avoid trainer deadlocks during sample coercion and borrow decompression
18
+ input after size coercion.
19
+ - Update GitHub Actions checkout to v7 and check Rust tests, formatting, and
20
+ Clippy in CI.
21
+
22
+ ## [0.2.0] - 2026-08-07
23
+
24
+ - Release the Ruby GVL around large frame/block compression and frame
25
+ decompression calls.
26
+ - Update the `lz4rip` crate dependency to 0.11.3.
27
+ - Replace Magnus with direct `rb-sys` bindings, add TruffleRuby build support,
28
+ and lower the Ruby requirement to 3.4.
29
+ - Add `max_decompressed_size:` to `Lz4rip::FrameCodec#decompress`, with the
30
+ cap enforced across concatenated frame output.
31
+ - Add RubyDoc metadata and move API reference details from `README.md` into
32
+ YARD comments.
33
+
5
34
  ## [0.1.2] - 2026-08-05
6
35
 
7
36
  - Update `lz4rip` crate dependency from 0.11.1 to 0.11.2.
data/Cargo.lock CHANGED
@@ -31,9 +31,9 @@ dependencies = [
31
31
 
32
32
  [[package]]
33
33
  name = "bitflags"
34
- version = "2.13.1"
34
+ version = "2.13.2"
35
35
  source = "registry+https://github.com/rust-lang/crates.io-index"
36
- checksum = "b588b76d00fde79687d7646a9b5bdf3cc0f655e0bbd080335a95d7e96f3587da"
36
+ checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"
37
37
 
38
38
  [[package]]
39
39
  name = "cexpr"
@@ -46,9 +46,9 @@ dependencies = [
46
46
 
47
47
  [[package]]
48
48
  name = "cfg-if"
49
- version = "1.0.4"
49
+ version = "1.0.5"
50
50
  source = "registry+https://github.com/rust-lang/crates.io-index"
51
- checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
51
+ checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
52
52
 
53
53
  [[package]]
54
54
  name = "clang-sys"
@@ -63,9 +63,9 @@ dependencies = [
63
63
 
64
64
  [[package]]
65
65
  name = "either"
66
- version = "1.17.0"
66
+ version = "1.19.0"
67
67
  source = "registry+https://github.com/rust-lang/crates.io-index"
68
- checksum = "9e5e8f6c15a24b9a3ee5efec809ccd006d3b30e8b3bb63c39af737c7f87daa1d"
68
+ checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be"
69
69
 
70
70
  [[package]]
71
71
  name = "glob"
@@ -84,15 +84,15 @@ dependencies = [
84
84
 
85
85
  [[package]]
86
86
  name = "lazy_static"
87
- version = "1.5.0"
87
+ version = "1.5.1"
88
88
  source = "registry+https://github.com/rust-lang/crates.io-index"
89
- checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
89
+ checksum = "20870f649af7073d53e38067b2a84312175d56ea15217e1b15bc83506ec50afb"
90
90
 
91
91
  [[package]]
92
92
  name = "libc"
93
- version = "0.2.189"
93
+ version = "0.2.190"
94
94
  source = "registry+https://github.com/rust-lang/crates.io-index"
95
- checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2"
95
+ checksum = "ce5d3ddc6d3fa000eb1536d85e147bfe31aacaba692ed6a876f95cb7c855be78"
96
96
 
97
97
  [[package]]
98
98
  name = "libloading"
@@ -106,18 +106,17 @@ dependencies = [
106
106
 
107
107
  [[package]]
108
108
  name = "lz4rip"
109
- version = "0.1.2"
109
+ version = "0.2.1"
110
110
  dependencies = [
111
- "lz4rip 0.11.2",
112
- "magnus",
111
+ "lz4rip 0.11.10",
113
112
  "rb-sys",
114
113
  ]
115
114
 
116
115
  [[package]]
117
116
  name = "lz4rip"
118
- version = "0.11.2"
117
+ version = "0.11.10"
119
118
  source = "registry+https://github.com/rust-lang/crates.io-index"
120
- checksum = "2cb69a12f600139f42d2c63d929b60733582f8bb706da4d2cd951e5beb6c649c"
119
+ checksum = "37d8ecd80125a8e67ebcaacd9fad5757efa2b6f5b875e1b4ce567814d758a419"
121
120
  dependencies = [
122
121
  "lz4rip-core",
123
122
  "lz4rip-decode",
@@ -127,51 +126,28 @@ dependencies = [
127
126
 
128
127
  [[package]]
129
128
  name = "lz4rip-core"
130
- version = "0.5.5"
129
+ version = "0.5.6"
131
130
  source = "registry+https://github.com/rust-lang/crates.io-index"
132
- checksum = "22fc4edb61fcaf1cdad24ac2982eff7af4417ef463c33bcf5c42ba549abd8b96"
131
+ checksum = "edb50206b4d66e3ec849d2e7ac9257d79c19733c435909a0a46cbb34f9ec7107"
133
132
 
134
133
  [[package]]
135
134
  name = "lz4rip-decode"
136
- version = "0.10.3"
135
+ version = "0.10.4"
137
136
  source = "registry+https://github.com/rust-lang/crates.io-index"
138
- checksum = "60d65bfd4c032fefcf8c18fb5f8d9958f4925146845db16dbc9d416f1566b9bf"
137
+ checksum = "d89c54c126f2acb3979c7d8fc9482506d6371438f514f2e83ef96ede9b585594"
139
138
  dependencies = [
140
139
  "lz4rip-core",
141
140
  ]
142
141
 
143
142
  [[package]]
144
143
  name = "lz4rip-encode"
145
- version = "0.10.5"
144
+ version = "0.10.8"
146
145
  source = "registry+https://github.com/rust-lang/crates.io-index"
147
- checksum = "09e92b7345788ec0d32b5e31051dc6a86730e17b01267e502e9ec2744b689d34"
146
+ checksum = "51a3509ddaac04400136c19f6a2d8427c18c46357eb584c9908b3ff476dcd13e"
148
147
  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"
@@ -214,18 +190,18 @@ dependencies = [
214
190
 
215
191
  [[package]]
216
192
  name = "rb-sys"
217
- version = "0.9.128"
193
+ version = "0.9.130"
218
194
  source = "registry+https://github.com/rust-lang/crates.io-index"
219
- checksum = "45ca28513560e56cfb79a62b1fce363c73af170a182024ce880c77ee9429920a"
195
+ checksum = "02faf625bb10ba893e3ae620f19c9fb1b5f8fcae0fe4eb86bb3f2230fad75edb"
220
196
  dependencies = [
221
197
  "rb-sys-build",
222
198
  ]
223
199
 
224
200
  [[package]]
225
201
  name = "rb-sys-build"
226
- version = "0.9.128"
202
+ version = "0.9.130"
227
203
  source = "registry+https://github.com/rust-lang/crates.io-index"
228
- checksum = "ce04b2c55eff3a21aaa623fcc655d94373238e72cac6b3e1a3641ff31649f99a"
204
+ checksum = "05be6f9c86fe5482808162826f6c047d093b3670582296c770de1d94f8066694"
229
205
  dependencies = [
230
206
  "bindgen",
231
207
  "lazy_static",
@@ -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"
@@ -308,15 +272,15 @@ dependencies = [
308
272
 
309
273
  [[package]]
310
274
  name = "twox-hash"
311
- version = "2.1.3"
275
+ version = "2.1.5"
312
276
  source = "registry+https://github.com/rust-lang/crates.io-index"
313
- checksum = "8464ec13c3691491391d9fce00f6416c9a48e46972f72d7865688be2080192c9"
277
+ checksum = "86a801b3cea342a06d468c8710662aa29e5e05e4f5c0d62f00bbb7f2ad7941c2"
314
278
 
315
279
  [[package]]
316
280
  name = "unicode-ident"
317
- version = "1.0.24"
281
+ version = "1.0.26"
318
282
  source = "registry+https://github.com/rust-lang/crates.io-index"
319
- checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
283
+ checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954"
320
284
 
321
285
  [[package]]
322
286
  name = "windows-link"
data/Cargo.toml CHANGED
@@ -6,4 +6,3 @@ resolver = "2"
6
6
  opt-level = 3
7
7
  lto = true
8
8
  codegen-units = 1
9
- panic = "abort"
data/README.md CHANGED
@@ -1,13 +1,13 @@
1
- # lz4rip — Ractor-safe LZ4 for Ruby
1
+ # lz4rip: Ractor-safe LZ4 for Ruby
2
2
 
3
3
  [![CI](https://github.com/paddor/lz4rip-rb/actions/workflows/ci.yml/badge.svg)](https://github.com/paddor/lz4rip-rb/actions/workflows/ci.yml)
4
4
  [![Gem Version](https://img.shields.io/gem/v/lz4rip?color=e9573f)](https://rubygems.org/gems/lz4rip)
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
6
- [![Ruby](https://img.shields.io/badge/Ruby-%3E%3D%204.0-CC342D?logo=ruby&logoColor=white)](https://www.ruby-lang.org)
6
+ [![Ruby](https://img.shields.io/badge/Ruby-%3E%3D%203.4-CC342D?logo=ruby&logoColor=white)](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 with [magnus](https://github.com/matsadler/magnus) and
10
- declared Ractor-safe so you can compress from any Ractor without a global lock.
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.0 and a Rust toolchain (for building the native extension):
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
- ## API
97
-
98
- | Class / Module | Method | Description |
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
 
@@ -1,16 +1,16 @@
1
1
  [package]
2
2
  name = "lz4rip"
3
- version = "0.1.2"
3
+ version = "0.2.1"
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.2", package = "lz4rip" }
12
- magnus = "0.8"
13
- rb-sys = "0.9"
12
+ lz4 = { version = "0.11.10", package = "lz4rip" }
13
+ rb-sys = "0.9.130"
14
14
 
15
15
  [build-dependencies]
16
- rb-sys = "0.9"
16
+ rb-sys = "0.9.130"
@@ -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
+ }