Skip to main content

weatherman_core/
lib.rs

1//! # weatherman-core
2//!
3//! Framework-free weather logic shared by the Iced GUI and Ratatui TUI, and
4//! usable as a **drop-in weather API provider library** on its own.
5//!
6//! | Module | What lives here |
7//! |--------|-----------------|
8//! | [`types`] | Domain models — conditions, locations, current/hourly/daily forecasts, config |
9//! | [`forecaster`] | [`WeatherProvider`] trait + Open-Meteo implementation ([`WeatherForecaster`]) |
10//! | [`location`] | IP + name geocoding ([`LocationService`]) |
11//! | [`api`] | One-call orchestration ([`load_report`]) returning a [`WeatherReport`] |
12//! | [`presentation`] | UI-agnostic view-model ([`ForecastView`]) + the [`tone_color_fn!`] macro |
13//! | [`format`] | UI-agnostic formatting helpers (units, wind, tones, local time) |
14//!
15//! This crate has NO GUI or TUI dependencies.
16//!
17//! ## Quick start
18//!
19//! ```no_run
20//! use weatherman_core::{load_report, ForecastView, WeatherConfig};
21//!
22//! # async fn run() -> anyhow::Result<()> {
23//! let report = load_report(&WeatherConfig::default(), Some("Berlin")).await?;
24//! let view = ForecastView::build(
25//!     report.current.as_ref(),
26//!     &report.hourly,
27//!     &report.daily,
28//!     &report.location,
29//!     &WeatherConfig::default(),
30//! );
31//! println!("{} days ready to render", view.days.len());
32//! # Ok(())
33//! # }
34//! ```
35
36pub mod api;
37pub mod forecaster;
38pub mod format;
39pub mod location;
40pub mod persistence;
41pub mod presentation;
42pub mod types;
43
44// Convenience re-exports — the public surface most consumers need.
45pub use api::{load_report, resolve_location, WeatherReport};
46pub use forecaster::{
47    weather_description_from_wmo, wmo_code_to_condition, WeatherForecaster, WeatherProvider,
48};
49pub use format::{
50    condition_tone, convert_to_local, day_label, format_date_short, format_local_time, is_daytime,
51    pop_percent, temp_unit_label, uv_label, weekday_name, wind_direction_arrow,
52    wind_direction_label, wind_unit_label, ConditionTone,
53};
54pub use location::LocationService;
55pub use persistence::{load_settings, save_settings, settings_path, AppSettings};
56pub use presentation::{
57    CurrentView, DayDetail, DayRow, ForecastView, HourRow, DAILY_LIMIT, HOURLY_LIMIT,
58};
59pub use types::{
60    CurrentConditions, CurrentWeather, DailyForecast, DetailLevel, Forecast, HourlyForecast,
61    Location, WeatherCondition, WeatherConfig, WeatherDescription,
62};