| Crates.io | codify_hoijui |
| lib.rs | codify_hoijui |
| version | 0.6.1 |
| created_at | 2023-12-04 04:56:10.07407+00 |
| updated_at | 2024-06-02 16:34:14.739359+00 |
| description | Helps in automatic code generation at compile-time, for initializing structs and enums containing data, which is to be available at runtime. |
| homepage | https://github.com/hoijui/codify-rs |
| repository | https://github.com/hoijui/codify-rs |
| max_upload_size | |
| id | 1057241 |
| size | 95,060 |
Helps in automatic code generation at compile-time, for initializing structs and enums containing data, which is to be available at runtime.
The practical use case of this, is to store resources/data in the binary in the most efficient form, so it will be ready at runtime, without having to include the data/files in their original, serialized, potentially innefficient form into the binary. This also means, the data does not have to be parsed at runtime/application-startup.
Add this library to your normal and build dependencies in cargo:
[dependencies]
codify = { version = "0.6", package = "codify_hoijui" }
[build-dependencies]
codify = { version = "0.6", package = "codify_hoijui" }
in your build.rs, load some data from resource files
into structs/enums, using serde
in your build.rs, call Codify::init_code() on that data,
creating init code.
write that code into a $OUT_DIR/my_data_x_gen.rs file
Create a proxy source file under src/ -
for example src/my_data_x_gen.rs -
which does nothing more then include the generated file:
include!(concat!(env!("OUT_DIR"), "/my_data_x_gen.rs"));
load/use $OUT_DIR/my_data_x.rs file at compile-time
For an example usage, see the build.rs file of osh-dir-std-rs project.