Skip to main content

Crate weatherman_core

Crate weatherman_core 

Source
Expand description

§weatherman-core

Framework-free weather logic shared by the Iced GUI and Ratatui TUI, and usable as a drop-in weather API provider library on its own.

ModuleWhat lives here
typesDomain models — conditions, locations, current/hourly/daily forecasts, config
forecasterWeatherProvider trait + Open-Meteo implementation (WeatherForecaster)
locationIP + name geocoding (LocationService)
apiOne-call orchestration (load_report) returning a WeatherReport
presentationUI-agnostic view-model (ForecastView) + the tone_color_fn! macro
[format]UI-agnostic formatting helpers (units, wind, tones, local time)

This crate has NO GUI or TUI dependencies.

§Quick start

use weatherman_core::{load_report, ForecastView, WeatherConfig};

let report = load_report(&WeatherConfig::default(), Some("Berlin")).await?;
let view = ForecastView::build(
    report.current.as_ref(),
    &report.hourly,
    &report.daily,
    &report.location,
    &WeatherConfig::default(),
);
println!("{} days ready to render", view.days.len());

Re-exports§

pub use api::load_report;
pub use api::resolve_location;
pub use api::WeatherReport;
pub use forecaster::weather_description_from_wmo;
pub use forecaster::wmo_code_to_condition;
pub use forecaster::WeatherForecaster;
pub use forecaster::WeatherProvider;
pub use format::condition_tone;
pub use format::convert_to_local;
pub use format::day_label;
pub use format::format_date_short;
pub use format::format_local_time;
pub use format::is_daytime;
pub use format::pop_percent;
pub use format::temp_unit_label;
pub use format::uv_label;
pub use format::weekday_name;
pub use format::wind_direction_arrow;
pub use format::wind_direction_label;
pub use format::wind_unit_label;
pub use format::ConditionTone;
pub use location::LocationService;
pub use persistence::load_settings;
pub use persistence::save_settings;
pub use persistence::settings_path;
pub use persistence::AppSettings;
pub use presentation::CurrentView;
pub use presentation::DayDetail;
pub use presentation::DayRow;
pub use presentation::ForecastView;
pub use presentation::HourRow;
pub use presentation::DAILY_LIMIT;
pub use presentation::HOURLY_LIMIT;
pub use types::CurrentConditions;
pub use types::CurrentWeather;
pub use types::DailyForecast;
pub use types::DetailLevel;
pub use types::Forecast;
pub use types::HourlyForecast;
pub use types::Location;
pub use types::WeatherCondition;
pub use types::WeatherConfig;
pub use types::WeatherDescription;

Modules§

api
High-level orchestration: resolve a location and load its full forecast.
forecaster
format
UI-agnostic formatting and presentation helpers shared by the GUI and TUI.
location
persistence
Persistent user settings — saved locations and preferred units.
presentation
UI-agnostic presentation view-model.
types

Macros§

tone_color_fn
Generate a ConditionTone -> Color function from a colour table, so each front-end defines its palette once without repeating the (identical) match structure. The generated function pairs naturally with the tone field on CurrentView, HourRow and DayRow.