codify_hoijui 0.6.1

Helps in automatic code generation at compile-time, for initializing structs and enums containing data, which is to be available at runtime.
Documentation
  • Coverage
  • 0%
    0 out of 3 items documented0 out of 2 items with examples
  • Size
  • Source code size: 94.73 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.21 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Homepage
  • hoijui/codify-rs
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • hoijui

codify-rs

License: AGPL-3.0-or-later REUSE status Repo Statistics Package Releases Documentation Releases Dependency Status Build Status

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.

Usage

  1. 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" }
    
  2. in your build.rs, load some data from resource files into structs/enums, using serde

  3. in your build.rs, call Codify::init_code() on that data, creating init code.

  4. write that code into a $OUT_DIR/my_data_x_gen.rs file

  5. 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"));

  6. load/use $OUT_DIR/my_data_x.rs file at compile-time

Example

For an example usage, see the build.rs file of osh-dir-std-rs project.