wbi_rs/lib.rs
1#![forbid(unsafe_code)]
2#![doc(
3 html_logo_url = "https://raw.githubusercontent.com/ArdentEmpiricist/wbi-rs/refs/heads/main/assets/logo.png"
4)]
5//! # `wbi_rs`
6//!
7//! A lightweight **Rust library + CLI** to fetch, store, visualize, and summarize
8//! [World Bank Indicators API](https://datahelpdesk.worldbank.org/knowledgebase/articles/889392-about-the-indicators-api-documentation)
9//! data.
10//!
11//! ## Highlights
12//! - Synchronous API client (`api::Client`)
13//! - Tidy data model (`models::DataPoint`)
14//! - Summary stats (`stats::grouped_summary`)
15//! - CSV/JSON export (`storage`)
16//! - SVG/PNG charts (`viz`) with legend placement, locale formatting, and multiple plot types
17//!
18//! ## Feature flags
19//! - `online`: enables live API tests/examples. (The library itself works without it.)
20//!
21//! Country-consistent styling is available as a runtime option via `viz::plot_chart(.., Some(true))` or the CLI `--country-styles` flag.
22//!
23//! ## Quick example
24//! ```no_run
25//! use wbi_rs::{Client, DateSpec};
26//! use wbi_rs::viz::{LegendMode, PlotKind};
27//!
28//! // 1) Fetch observations
29//! let client = Client::default();
30//! let data = client.fetch(
31//! &["DEU".into(), "USA".into()],
32//! &["SP.POP.TOTL".into()],
33//! Some(DateSpec::Range { start: 2010, end: 2020 }),
34//! None,
35//! )?;
36//!
37//! // 2) Plot to SVG (line chart, legend on the right, English locale)
38//! wbi_rs::viz::plot_chart(
39//! &data,
40//! "pop.svg",
41//! 1000,
42//! 600,
43//! "en",
44//! LegendMode::Right,
45//! "Population (2010–2020)",
46//! PlotKind::Line,
47//! 0.3, // loess_span (ignored unless PlotKind::Loess)
48//! None, // no country styles in tests
49//! )?;
50//!
51//! // 3) Print grouped summary stats
52//! let summaries = wbi_rs::stats::grouped_summary(&data);
53//! for s in summaries {
54//! println!("{:?}", s);
55//! }
56//! # Ok::<(), anyhow::Error>(())
57//! ```
58
59pub mod api;
60pub mod models;
61pub mod stats;
62pub mod storage;
63pub mod viz;
64pub mod viz_plotters_adapter;
65pub mod viz_style;
66
67// Country-consistent styling module (always available)
68pub mod style;
69
70pub use api::Client;
71pub use models::{DataPoint, DateSpec, GroupKey};