Class: Lz4rip::FrameCodec
- Inherits:
-
Object
- Object
- Lz4rip::FrameCodec
- Defined in:
- lib/lz4rip/frame_codec.rb
Overview
LZ4 frame-format codec.
FrameCodec is Ractor-shareable.
Class Method Summary collapse
-
._native_new(dict, id) ⇒ FrameCodec
Native constructor used by
.new. -
.new(dict: nil) ⇒ FrameCodec
Create a frame codec.
Instance Method Summary collapse
-
#_decompress(bytes, max_decompressed_size) ⇒ String
Native decompression entry used by #decompress.
-
#compress(bytes) ⇒ String
Compress bytes to an LZ4 frame.
-
#decompress(bytes, max_decompressed_size: nil) ⇒ String
Decompress an LZ4 frame.
- #has_dict? ⇒ Boolean
-
#id ⇒ Integer?
Dictionary ID.
-
#size ⇒ Integer
Dictionary size in bytes.
Class Method Details
._native_new(dict, id) ⇒ FrameCodec
Native constructor used by .new.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/lz4rip/frame_codec.rb', line 48 class FrameCodec 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 Lz4rip::Dictionary, String, or nil; got #{dict.class}" end end def decompress(bytes, max_decompressed_size: nil) _decompress(bytes, max_decompressed_size) end end |
.new(dict: nil) ⇒ FrameCodec
Create a frame codec.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/lz4rip/frame_codec.rb', line 48 class FrameCodec 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 Lz4rip::Dictionary, String, or nil; got #{dict.class}" end end def decompress(bytes, max_decompressed_size: nil) _decompress(bytes, max_decompressed_size) end end |
Instance Method Details
#_decompress(bytes, max_decompressed_size) ⇒ String
Native decompression entry used by #decompress.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/lz4rip/frame_codec.rb', line 48 class FrameCodec 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 Lz4rip::Dictionary, String, or nil; got #{dict.class}" end end def decompress(bytes, max_decompressed_size: nil) _decompress(bytes, max_decompressed_size) end end |
#compress(bytes) ⇒ String
Compress bytes to an LZ4 frame.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/lz4rip/frame_codec.rb', line 48 class FrameCodec 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 Lz4rip::Dictionary, String, or nil; got #{dict.class}" end end def decompress(bytes, max_decompressed_size: nil) _decompress(bytes, max_decompressed_size) end end |
#decompress(bytes, max_decompressed_size: nil) ⇒ String
Decompress an LZ4 frame.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/lz4rip/frame_codec.rb', line 48 class FrameCodec 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 Lz4rip::Dictionary, String, or nil; got #{dict.class}" end end def decompress(bytes, max_decompressed_size: nil) _decompress(bytes, max_decompressed_size) end end |
#has_dict? ⇒ Boolean
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/lz4rip/frame_codec.rb', line 48 class FrameCodec 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 Lz4rip::Dictionary, String, or nil; got #{dict.class}" end end def decompress(bytes, max_decompressed_size: nil) _decompress(bytes, max_decompressed_size) end end |
#id ⇒ Integer?
Returns dictionary ID.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/lz4rip/frame_codec.rb', line 48 class FrameCodec 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 Lz4rip::Dictionary, String, or nil; got #{dict.class}" end end def decompress(bytes, max_decompressed_size: nil) _decompress(bytes, max_decompressed_size) end end |
#size ⇒ Integer
Returns dictionary size in bytes.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/lz4rip/frame_codec.rb', line 48 class FrameCodec 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 Lz4rip::Dictionary, String, or nil; got #{dict.class}" end end def decompress(bytes, max_decompressed_size: nil) _decompress(bytes, max_decompressed_size) end end |