Compression at compiletime


#1

Hi,

is there an include_str! like macro that does compression at compile-time and decompression at execution-time?


#2

I don’t think there’s such a thing. Maybe you could compress the file yourself and use include_bytes!, and decompress that at runtime?


#3

Currently, you’d probably have to do this using a build.rs script.


#4

Sounds like a great idea though! Maybe someone could create it?


#5

As you can depend on any crate to be used in build.rs http://doc.crates.io/build-script.html#build-dependencies this would be quite easy to achieve. You could then use https://doc.rust-lang.org/stable/std/macro.include_bytes!.html to include a bunch of bytes with the result and then decompress at run-time.

There are a bunch of crates for compression on https://crates.io/search?q=compression so you should be able to pick the one that fits your needs best.