staticfilemap
Procedural macro to embed optionally compressed files during compilation.
Similar to include_file! or include_dir!, but accepts a list of files that can be specified through environment variables and supports compression with LZ4 or zstd.
Usage
Derive from StaticFileMap to create a map.
Specify the files to be included and the names they should be accessed by with the files and names attributes.
These can either be strings containing values separated with ;, or environment variables containing them when the parse attribute is set to env.
Relative paths are resolved relative to CARGO_MANIFEST_DIR. If the names attribute is not specified, the names are inferred from the filenames.
The compression level is controlled by the compression attribute. With a compression level above 0 the included files are compresed with LZ4. LZ4 accepts a compression level up to 12.
Alternatively, zstd can be used for compression by setting the algorithm attribute to zstd. Zstd supports a compression level up to 21.
The cargo features lz4 and zstd are available to select compression support. lz4 is enabled by default.
Files can be accessed as &'static [u8] slices by the get(name) and get_match(name) functions at runtime.
get_match(name) accepts partial names if only one name matches. keys() returns a list of all keys.
See the examples, the tests or the implementation for details.
Dependency
[]
= "^0.3"
Examples
use StaticFileMap;
;
use StaticFileMap;
use Decode;
use Read;
;
use StaticFileMap;
use decode_all;
;
use StaticFileMap;
;