| Crates.io | wearust |
| lib.rs | wearust |
| version | 0.1.4 |
| created_at | 2025-08-14 01:32:27.302204+00 |
| updated_at | 2025-08-21 22:32:52.592453+00 |
| description | Async Rust library for fetching weather and location data using WeatherAPI |
| homepage | https://github.com/idorocodes/wearust |
| repository | https://github.com/idorocodes/wearust |
| max_upload_size | |
| id | 1794316 |
| size | 51,019 |
A Rust library for fetching current weather and location data from WeatherAPI. It uses async Rust with Tokio, safe JSON parsing with serde, and hides away the messy API boilerplate so you just call a function and get typed data back.
> cargo install wearust
Add this to your Cargo.toml:
[dependencies]
wearust = "0.1.4"
tokio = { version = "1", features = ["full"] }
reqwest = { version = "0.11", features = ["json"] }
serde = { version = "1.0", features = ["derive"] }
anyhow = "1.0"
chrono = { version = "0.4", features = ["serde"] }
use wearust::{find_location, find_weather};
use tokio;
#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
let api_key = "your_api_key"; //get it from weatherapi.com
let city_name = "your_prefered_city"
// Fetch location info
let location_info = find_location(city_name, api_key).await?;
println!("City name : {}", location_info.location.name);
println!("Country : {}", location_info.location.country);
println!("Region : {}", location_info.location.region);
println!("Latitude : {}", location_info.location.lat);
println!("Longitude : {}", location_info.location.lon);
println!("Date : {}", location_info.location.localtime.date());
println!("Time : {}", location_info.location.localtime.time());
// Fetch current weather
let weather = find_weather("Lagos", api_key).await?;
println!("Last Updated: {}", weather.current.last_updated);
println!("Temperature in Celsius : {}°C", weather.current.temp_c);
println!("Temperature in Fahrenheit : {}°F", weather.current.temp_f);
println!("Weather Condition : {}", weather.current.condition.text);
println!("Weather Icon : {}", weather.current.condition.icon);
Ok(())
}