Skip to main content

use_meteorology/
lib.rs

1#![forbid(unsafe_code)]
2#![doc = include_str!("../README.md")]
3
4pub use use_air_temperature as air_temperature;
5pub use use_atmosphere as atmosphere;
6pub use use_atmospheric_pressure as atmospheric_pressure;
7pub use use_cloud as cloud;
8pub use use_humidity as humidity;
9pub use use_precipitation as precipitation;
10pub use use_pressure_system as pressure_system;
11pub use use_weather_forecast as weather_forecast;
12pub use use_weather_front as weather_front;
13pub use use_weather_observation as weather_observation;
14pub use use_wind as wind;
15
16pub mod prelude;
17
18#[cfg(test)]
19mod tests {
20    use super::prelude::{
21        AirTemperature, AtmosphericPressure, CloudCover, CloudKind, ForecastConfidence,
22        ForecastHorizon, ForecastId, ForecastKind, ObservationKind, ObservationQuality,
23        ObservationSource, PrecipitationAmount, PrecipitationIntensity, PrecipitationKind,
24        PressureSystemKind, PressureSystemName, RelativeHumidity, WeatherFrontKind,
25        WeatherObservation, WeatherObservationId, WindDirection, WindSpeed,
26    };
27
28    #[test]
29    fn facade_composes_meteorology_primitives_without_prediction() {
30        let observation = WeatherObservation::new(
31            WeatherObservationId::new("obs-100").unwrap(),
32            ObservationKind::Surface,
33            ObservationSource::new("automated station").unwrap(),
34            ObservationQuality::Verified,
35        );
36        let temperature = AirTemperature::new(17.5).unwrap();
37        let pressure = AtmosphericPressure::new(1011.6).unwrap();
38        let humidity = RelativeHumidity::new(71.0).unwrap();
39        let wind_speed = WindSpeed::new(4.8).unwrap();
40        let wind_direction = WindDirection::new(140.0).unwrap();
41        let cloud_kind = CloudKind::Altocumulus;
42        let cloud_cover = CloudCover::new(5).unwrap();
43        let precipitation_kind = PrecipitationKind::Rain;
44        let precipitation_amount = PrecipitationAmount::new(2.4).unwrap();
45        let precipitation_intensity = PrecipitationIntensity::Light;
46        let front_kind = WeatherFrontKind::Cold;
47        let pressure_system_name = PressureSystemName::new("Prairie Low").unwrap();
48        let pressure_system_kind = PressureSystemKind::Low;
49        let forecast_id = ForecastId::new("fcst-100").unwrap();
50        let forecast_kind = ForecastKind::ShortRange;
51        let forecast_horizon = ForecastHorizon::new(12);
52        let forecast_confidence = ForecastConfidence::Medium;
53
54        assert_eq!(observation.kind(), &ObservationKind::Surface);
55        assert_eq!(temperature.celsius(), 17.5);
56        assert_eq!(pressure.hectopascals(), 1011.6);
57        assert_eq!(humidity.percent(), 71.0);
58        assert_eq!(wind_speed.meters_per_second(), 4.8);
59        assert_eq!(wind_direction.degrees_from_north(), 140.0);
60        assert_eq!(cloud_kind.to_string(), "altocumulus");
61        assert_eq!(cloud_cover.oktas(), 5);
62        assert_eq!(precipitation_kind.to_string(), "rain");
63        assert_eq!(precipitation_amount.millimeters(), 2.4);
64        assert_eq!(precipitation_intensity.to_string(), "light");
65        assert_eq!(front_kind.to_string(), "cold");
66        assert_eq!(pressure_system_name.as_str(), "Prairie Low");
67        assert_eq!(pressure_system_kind.to_string(), "low");
68        assert_eq!(forecast_id.as_str(), "fcst-100");
69        assert_eq!(forecast_kind.to_string(), "short-range");
70        assert_eq!(forecast_horizon.hours(), 12);
71        assert_eq!(forecast_confidence.to_string(), "medium");
72    }
73}