1use std::time::Duration;
4use ureq::Agent;
5
6pub mod air_quality;
7pub mod api;
8pub mod climate_change;
9pub mod elevation;
10pub mod ensemble_weather;
11pub mod flood;
12pub mod geocoding;
13pub mod historical_weather;
14pub mod marine_weather;
15pub mod satellite_radiation;
16pub mod weather;
17pub mod weather_api_generated;
18
19pub struct OpenMeteoClient {
20 agent: Agent,
21}
22
23impl Default for OpenMeteoClient {
24 fn default() -> Self {
25 let config = Agent::config_builder()
26 .timeout_global(Some(Duration::from_secs(5)))
27 .build();
28 let agent: Agent = config.into();
29 OpenMeteoClient { agent }
30 }
31}
32
33pub struct WeatherData {
35 buffer: Vec<u8>,
36}
37
38impl WeatherData {
39 pub fn from_buffer(buffer: Vec<u8>) -> Self {
40 Self { buffer }
41 }
42
43 pub fn decode_buffer(&self) -> Result<WeatherApiResponse, ureq::Error> {
45 size_prefixed_root_as_weather_api_response(&self.buffer)
46 .map_err(|e| ureq::Error::BadUri(format!("Failed to parse: {}", e)))
47 }
48}
49
50pub use air_quality::*;
52pub use climate_change::*;
53pub use elevation::*;
54pub use ensemble_weather::*;
55pub use flood::*;
56pub use geocoding::*;
57pub use historical_weather::*;
58pub use marine_weather::*;
59pub use satellite_radiation::*;
60pub use weather::*;
61use weather_api_generated::openmeteo_sdk::{
62 WeatherApiResponse, size_prefixed_root_as_weather_api_response,
63};
64pub use weather_api_generated::*;