7 releases

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

#1519 in Procedural macros

Download history 4037/week @ 2023-12-23 3208/week @ 2023-12-30 3888/week @ 2024-01-06 3974/week @ 2024-01-13 4178/week @ 2024-01-20 5049/week @ 2024-01-27 4750/week @ 2024-02-03 4153/week @ 2024-02-10 7393/week @ 2024-02-17 5238/week @ 2024-02-24 6619/week @ 2024-03-02 5140/week @ 2024-03-09 5326/week @ 2024-03-16 6918/week @ 2024-03-23 5263/week @ 2024-03-30 4994/week @ 2024-04-06

23,508 downloads per month
Used in 87 crates (2 directly)

Apache-2.0

16KB
296 lines

include-flate

!CI crates.io docs.rs

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

Why?

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.

Warning

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.

Dependencies

~6MB
~103K SLoC