Class: RLZ4::FrameCodec
- Inherits:
-
Object
- Object
- RLZ4::FrameCodec
- Defined in:
- lib/rlz4/frame_codec.rb
Class Method Summary collapse
-
.new(dict: nil) ⇒ Object
Frame-format LZ4 codec, optionally dict-bound.
Class Method Details
.new(dict: nil) ⇒ Object
Frame-format LZ4 codec, optionally dict-bound. Parallel in shape to BlockCodec, but emits a real LZ4 frame (magic ‘04 22 4D 18`) with the FLG.DictID bit set and `Dict_ID` written into the FrameDescriptor when a dict is installed. Output is interoperable with the reference `lz4` CLI given the same dictionary file.
Unlike BlockCodec, FrameCodec holds no thread-local mutable state: it’s a read-only dict bytes buffer plus a derived id. Shareable across Ractors.
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rlz4/frame_codec.rb', line 21 def self.new(dict: nil) case dict when nil _native_new(nil, 0) when Dictionary _native_new(dict.bytes, dict.id) when String _native_new(dict, Dictionary.new(bytes: dict).id) else raise TypeError, "expected RLZ4::Dictionary, String, or nil; got #{dict.class}" end end |