france_api_adresse/
lib.rs

1//! A minimal wrapper for the Base Adresse Nationale "BAN" french geo API.
2//!
3//! This crate provides functions to query geographical address information
4//! from the [Base Adresse Nationale](https://adresse.data.gouv.fr/) API.
5//!
6//! # Features
7//! - Forward geocoding: convert address strings into coordinates
8//! - Reverse geocoding: convert coordinates into address details
9//!
10//! # Example
11//! ```rust
12//! use france_api_adresse;
13//! let api = france_api_adresse::client::BAN::default();
14//! let search = api.geocode("Route du marais".to_string());
15//!
16//! // Narrow the results to post code 74380
17//! let search = search.postcode("74380");
18//!
19//! // Narrow the results to city "Cranves-Sales"
20//! let search = search.city("Cranves-Sales".to_string());
21//!
22//! // Get the results
23//! let result = search.execute_blocking().unwrap();
24//! for result in result.features {
25//!     println!("Address: {}", result.properties.label);
26//!     println!("Coords: {:?}", result.geometry.coordinates);
27//! }
28//! ```
29//!
30//! You can use async mode by enabling the `async` feature in your `Cargo.toml`. Example:
31//! ```rust
32//! #[tokio::main]
33//! async fn main() {
34//!     let api = france_api_adresse::client::BAN::default();
35//!     let search = api.geocode("Route du marais".to_string());
36//!     let results = search.execute_async().await.unwrap();
37//! }
38//! ```
39
40//!
41//! # Errors
42//! Errors are returned as a custom `Error` enum to distinguish between HTTP,
43//! text extraction, and JSON deserialization failures.
44//!
45//!
46
47pub mod client;
48pub mod geocode;
49pub mod reverse;
50pub mod types;