open-meteo / sdk

Open-Meteo schema files
MIT License
24 stars 15 forks source link

Rust support/sdk #129

Open feefladder opened 2 weeks ago

feefladder commented 2 weeks ago

The readme said to make an issue requesting a language, so here it is.

Is this a maybe/yes/no?

patrick-zippenfenig commented 2 weeks ago

I quickly added the compiled rust flatbuffer files: https://github.com/open-meteo/sdk/blob/781b2078cd0d1c79d14a10afb5951ae0140a54a8/rust/weather_api_generated.rs

The API returns multiple length-prefixed flat buffer messages. To decode a message, take the first 4 bytes to get the length of a message, then decode it using flatbuffers and repeat:

https://github.com/open-meteo/sdk/blob/main/swift/Sources/OpenMeteoSdk/OpenMeteoSdk.swift#L84-L94

Python example here: https://github.com/open-meteo/python-requests/blob/66a750440e22f08fe5396038fb0859f62ac8af1c/openmeteo_requests/Client.py#L25

Do you have experience in using HTTP clients in Rust and could give it a try? Afterwards this could be bundled into a crate.