noritada / grib-rs

GRIB format parser for Rust
Apache License 2.0
57 stars 9 forks source link

Submessage filtering improvement part 3: code generation from wgrib2's parameter code table files #101

Closed noritada closed 2 months ago

noritada commented 2 months ago

This PR provides implementation of code generation from wgrib2's parameter code table files.

This PR adds "grib-codegen" crate which provides an attribute macro parameter_codes. Using this macro, users can create enums with variants of parameter abbreviation codes from table files.

#[parameter_codes(path = "path/to/table")]
pub enum FooCodes {}

An associated function for remapping is also generated to address an issue that sometimes the same abbreviation code is assigned to multiple parameters.

There are still some issues with this macro that will be addressed in subsequent PRs.

Note that the generated code uses std::cell::LazyCell, which was stabilized in Rust 1.80.0 released 2 months ago on July 25, 2024.