dart_lz4 library
Pure Dart LZ4 and LZ4HC APIs.
This library provides:
- LZ4 block compression/decompression.
- LZ4 frame encode/decode (including skippable frames).
- Streaming frame encode/decode as
StreamTransformers.
All APIs are Uint8List-based and are intended to work on all Dart
platforms, including Web.
Classes
- Lz4FrameInfo
- Metadata about an LZ4 frame.
- Lz4FrameOptions
- Options controlling LZ4 frame encoding.
- Lz4HcOptions
- Options for tuning LZ4 HC (High Compression) mode.
Enums
- Lz4CompressionLevel
- Compression level for lz4Compress.
- Lz4FrameBlockSize
- Maximum LZ4 frame block size.
- Lz4FrameCompression
- Compression mode used for each LZ4 frame block.
Functions
-
lz4Compress(
Uint8List src, {Lz4CompressionLevel level = Lz4CompressionLevel.fast, int acceleration = 1, Lz4HcOptions? hcOptions}) → Uint8List -
Compresses
srcinto an LZ4 block. -
lz4CompressWithSize(
Uint8List src, {Lz4CompressionLevel level = Lz4CompressionLevel.fast, int acceleration = 1}) → Uint8List -
Compresses
srcinto an LZ4 block with the decompressed size prepended. -
lz4Decompress(
Uint8List src, {required int decompressedSize}) → Uint8List -
Decompresses an LZ4 block
srcinto a new Uint8List. -
lz4DecompressWithSize(
Uint8List src) → Uint8List - Decompresses an LZ4 block that was compressed with lz4CompressWithSize.
-
lz4FrameDecode(
Uint8List src, {int? maxOutputBytes, Lz4DictionaryResolver? dictionaryResolver}) → Uint8List -
Decodes one or more concatenated LZ4 frames from
src. -
lz4FrameDecoder(
{int? maxOutputBytes, Lz4DictionaryResolver? dictionaryResolver}) → StreamTransformer< List< int> , List<int> > -
Returns a
StreamTransformerthat decodes LZ4 frames from a byte stream. -
lz4FrameEncode(
Uint8List src, {int acceleration = 1, Uint8List? dictionary}) → Uint8List -
Encodes
srcas an LZ4 frame. -
lz4FrameEncoder(
{int acceleration = 1, Uint8List? dictionary}) → StreamTransformer< List< int> , List<int> > -
Returns a
StreamTransformerthat encodes bytes into a single LZ4 frame. -
lz4FrameEncoderWithOptions(
{required Lz4FrameOptions options, Uint8List? dictionary}) → StreamTransformer< List< int> , List<int> > -
Returns a
StreamTransformerthat encodes bytes into a single LZ4 frame using the providedoptions. -
lz4FrameEncodeWithOptions(
Uint8List src, {required Lz4FrameOptions options, Uint8List? dictionary}) → Uint8List -
Encodes
srcas an LZ4 frame using the providedoptions. -
lz4FrameInfo(
Uint8List src) → Lz4FrameInfo -
Parses the header of an LZ4 frame from
srcand returns its metadata. -
lz4LegacyEncode(
Uint8List src, {int acceleration = 1}) → Uint8List -
Encodes
srcas a legacy LZ4 frame (magic0x184C2102). -
lz4SkippableEncode(
Uint8List data, {int index = 0}) → Uint8List -
Encodes a skippable frame containing
data.
Typedefs
- Lz4DictionaryResolver = Uint8List? Function(int dictId)
- Callback to resolve a dictionary by its ID.
Exceptions / Errors
- Lz4CorruptDataException
- Thrown when the compressed data is corrupt (e.g. checksum mismatch, invalid block).
- Lz4Exception
- Base class for all LZ4-related exceptions.
- Lz4FormatException
- Thrown when the LZ4 frame format is invalid (e.g. bad magic number, invalid header).
- Lz4OutputLimitException
- Thrown when the output buffer is too small to contain the uncompressed data.
- Lz4UnsupportedFeatureException
- Thrown when a feature is not supported by this implementation (e.g. unknown version).