Skip to content

Minimal no_std implementation of Heatshrink compression & decompression

License

Notifications You must be signed in to change notification settings

mean00/heatshrink

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

heatshrink_byte

This is a modified version of the https://github.com/snakehand/heatshrink

Description

The main difference is you decompress/read the decompressed data byte per byte.

It is useful for use cases such as font compression etc.. where the output can be big and you process them in little chunks (byte)

You need to know the output size, it is driven by the consumer NOT by the compressed data size. In other words, you are expected to stop consuming when the original data have been retrieved.

/!\ The window size is hardcoded to be 7 maximum, length =4 /!\

This is to cap the consumed buffer memory to about 256 bytes

CLI encoder

To get a basic CLI encoder:\

cargo build - * -features=encode*

the resulting executable is in target/debug/heatshrink-rust

Usage

let hs = heatshrink::HeatshrinkDecoder::new( &compressed_data, &(heatshrink::Config::new(7,4).unwrap()));
while(you need data) {let one_bye=hs.next();}\

or if you want to decompress later

let hs = heatshrink::HeatshrinkDecoder::new( &[], & heatshrink::Config::new(7,4).unwrap()));
...
...
hs.reset(&compressed_data);
while(you need data) {let one_bye=hs.next();}

The &[] can be replaced by the compressed data if it is a simple use case.
hs.reset(data_to_decode); // if you want to decode another buffer

Warning

1- As far as i can tell, the compressed binaries are not necessarily compatible with original C language heatshrink!.

Use the encoder from heatshrink rust.

The binaries generated by this version are compatible with the original snakehand version.

2- Make sure the encoder & decoder have the same configuration. I strongly suggest to use the default 7/4 that are more or less hardcoded anyway.

3- There is little error handling by design.

--

Original description :

Minimal no_std implementation of Heatshrink compression & decompression

About

Minimal no_std implementation of Heatshrink compression & decompression

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%