ScaleWeather / eccodes

Unofficial high-level Rust bindings of the latest ecCodes release.
Apache License 2.0
7 stars 6 forks source link

initial index-support #2

Closed asura6 closed 8 months ago

asura6 commented 1 year ago

I've had a go at adding rudimentary index support. This is the first time I'm using rust except for writing hello world so please take a closer look and feel free to adjust to your liking!

A CodesIndex type can now be constructed from a preexisting index-file. I've added one used in tests in the data-directory for one of the icelandic grib-file examples.

The CodesIndex has a Select trait that is used to select the index-keys. The underlying C-api has different select-functions depending on the value type. I implemented the select-trait to call the corresponding one depending on the value type in the function call instead.

The CodesIndex can convert into a CodesHandle, but the CodesHandle type makes assumptions about being created from files. I've done my best to work around this. Even if an index-file doesn't already exist, creating one in memory is a nice and performant alternative to iterating through messages. I have however not implemented any of these features.

Due to the CodesHandle not being backed by file-data I also implemented a conversion from a GribHandle to a KeyedMessage without using an iterator since it won't work without an actual resource backing the GribHandle.