A Rust wrapper for the Oodle compression library. Loads the Oodle shared library at runtime via libloading, providing safe access to compress and decompress functions.
cargo add oodleYou must have the Oodle shared library (.dll, .so, or .dylib) available on your system. The library is loaded at runtime by path.
use oodle::Oodle;
let oodle = Oodle::load("path/to/oo2core.dll")?;Oodle is Send + Sync, so it can be shared across threads.
use oodle::{Oodle, OodleCompressor, OodleCompressionLevel};
let oodle = Oodle::load("path/to/oo2core.dll")?;
let input = b"some data to compress";
let max_size = oodle.get_compressed_buffer_size_needed(OodleCompressor::Kraken, input.len());
let mut output = vec![0u8; max_size];
let compressed_size = oodle.compress(
OodleCompressor::Kraken,
OodleCompressionLevel::Normal,
input,
&mut output,
)?;
output.truncate(compressed_size);use oodle::Oodle;
let oodle = Oodle::load("path/to/oo2core.dll")?;
let mut decompressed = vec![0u8; original_size];
let result = oodle.decompress(&compressed_data, &mut decompressed)?;use oodle::{Oodle, OodleFuzzSafe, OodleCheckCrc, OodleVerbosity, OodleDecodeThreadPhase};
let oodle = Oodle::load("path/to/oo2core.dll")?;
let mut decompressed = vec![0u8; original_size];
let result = oodle.decompress_with_options(
&compressed_data,
&mut decompressed,
OodleFuzzSafe::Yes,
OodleCheckCrc::Yes,
OodleVerbosity::None,
OodleDecodeThreadPhase::All,
)?;// Get the decode buffer size (with corruption safety margin)
let buf_size = oodle.get_decode_buffer_size(OodleCompressor::Kraken, raw_size, true);
// Get the scratch memory bound for compression
let scratch = oodle.get_compress_scratch_mem_bound(
OodleCompressor::Kraken,
OodleCompressionLevel::Normal,
raw_size,
);| Compressor | Value |
|---|---|
| Invalid | -1 |
| None | 3 |
| Kraken | 8 |
| Mermaid | 9 |
| Selkie | 11 |
| Hydra | 12 |
| Leviathan | 13 |
HyperFast4 (-4) through HyperFast1 (-1), None (0), SuperFast (1), VeryFast (2), Fast (3), Normal (4), Optimal1 (5) through Optimal5 (9)
Oodle::load returns Result<Oodle, Error> where Error is:
LibLoadError— the shared library could not be loadedFunctionLoadError— a required function symbol was not found in the library
compress and decompress return Result<usize, Error> where additional variants are:
CompressFailed— Oodle returnedOODLELZ_FAILED(0)DecompressFailed— Oodle returnedOODLELZ_FAILED(0)
Error implements Display and std::error::Error.
Integration tests require the Oodle shared library. They are #[ignore]d by default.
OODLE_LIB_PATH=/path/to/oo2core.so cargo test -- --ignoredMIT