Expand description
sarzamin is a comprehensive Rust library for accessing geographical data of Iran,
including provinces, counties, cities, districts, and rural districts.
Data is loaded from JSON files at compile-time, ensuring zero runtime dependencies and high performance after the initial lazy-load.
§Examples
use sarzamin::{get_all_provinces, find_province_by_city_name};
// Get all provinces
let provinces = get_all_provinces();
assert_eq!(provinces.len(), 31); // Based on the full dataset
println!("Province of Tehran: {:?}", provinces.iter().find(|p| p.name == "تهران"));
// Find the province of a city
if let Some(province) = find_province_by_city_name("شیراز") {
assert_eq!(province.name, "فارس");
println!("'شیراز' is in '{}' province.", province.name);
}Re-exports§
pub use models::City;pub use models::County;pub use models::District;pub use models::Province;pub use models::RuralDistrict;
Modules§
Functions§
- find_
province_ by_ city_ name - Finds the province of a city by its name. This function performs a case-sensitive search.
- find_
province_ by_ id - Finds a province by its ID.
- get_
all_ cities - Returns a slice of all cities.
- get_
all_ counties - Returns a slice of all counties.
- get_
all_ provinces - Returns a slice of all provinces.
- get_
cities_ of_ province - Returns a vector of cities belonging to a specific province.
- get_
counties_ of_ province - Returns a vector of counties belonging to a specific province.