#deflate #assets #macro #include


A variant of include_bytes!/include_str! with compile-time deflation and runtime lazy inflation

7 releases

0.3.0 Oct 15, 2023
0.2.0 Feb 13, 2023
0.1.4 Nov 19, 2021
0.1.3 Sep 3, 2019
0.1.2 Aug 14, 2019

#530 in Rust patterns

Download history 5790/week @ 2024-02-21 6262/week @ 2024-02-28 5901/week @ 2024-03-06 5428/week @ 2024-03-13 6805/week @ 2024-03-20 5984/week @ 2024-03-27 5499/week @ 2024-04-03 7627/week @ 2024-04-10 6061/week @ 2024-04-17 4489/week @ 2024-04-24 4801/week @ 2024-05-01 5816/week @ 2024-05-08 5403/week @ 2024-05-15 6469/week @ 2024-05-22 6527/week @ 2024-05-29 5457/week @ 2024-06-05

24,626 downloads per month
Used in 89 crates (14 directly)


71 lines


!CI crates.io docs.rs

A variant of include_bytes!/include_str! with compile-time deflation and runtime lazy inflation.


include_bytes!/include_str! are great for embedding resources into an executable/library without involving the complex logistics of maintaining an assets manager. However, they are copied as-is into the artifact, leading to unnecessarily large binary size. This library automatically compresses the resources and lazily decompresses them at runtime, allowing smaller binary sizes.

Nevertheless, this inevitably leads to wasting RAM to store both the compressed and decompressed data, which might be undesirable if the data are too large. An actual installer is still required if the binary involves too many resources that do not need to be kept in RAM all time.


This library compresses included data independently. It is usually more effective to compress the whole output binary together (e.g. distributing .exe.gz ) than to compress independently. In addition, compression algorithms usually produce smaller artifacts by processing the raw input together than by processing already-compressed output. #[cfg_attr] might come handy for conditionally using compression or direct data inclusion.


~54K SLoC