0 purchases
dart native compression
dart_native_compression #
#
LZ4 #
The lz4 in this library is a ffi binding to lz4 v1.9.3, the compressed block and frame format are both interoperable with official C api, as well as other interoperable ports, bindings and CLI tools.
Getting Started
import 'dart:ffi';
import 'package:dart_native_compression/dart_native_compression.dart';
final lz4 = Lz4Lib(lib: DynamicLibrary.open('libnative_compression.so'));
print('LZ4 version number: ${lz4.getVersioinNumber()}');
copied to clipboard
To compress data into a lz4 frame
final compressedFrame = lz4.compressFrame(data);
copied to clipboard
To decompress a lz4 frame with a single function
final decompressed = lz4.decompressFrame(compressedFrame);
copied to clipboard
To decompress a lz4 frame with stream api
await for (final decompressedChunk
in lz4.decompressFrameStream(compressedStream)) {
// Your logic here
}
copied to clipboard
To get more examples
Go to unit test
To run unit tests #
pub get && pub run test
copied to clipboard
To build native lib (libnative_compression.so) #
install rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
copied to clipboard
pull submodules
git submodule update --init --recursive
copied to clipboard
go to native_compression directory, run
cargo build --release --all-features
copied to clipboard
to cross compile to different target
cargo lipo --release --targets=aarch64-apple-ios,x86_64-apple-ios,armv7-apple-ios,armv7s-apple-ios
cargo build --target aarch64-linux-android --release
cargo build --target armv7-linux-androideabi --release
cargo build --target i686-linux-android --release
copied to clipboard
The shared library will be under target/release . It would be libdart_native_compression.so, dart_native_compression.dll, libdart_native_compression.dylib on linux, windows, osx respectively.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.