ng-postcode 0.5.5

Validate, parse and format Nigerian postcodes (postal codes) offline: Nigeria's 11-character NIPOST digital postcode (NDAPS). Includes a client for the postcode.gov.ng API.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
//! NG_POSTCODE_API_KEY=... cargo run --features client --example lookup -- FC-03-B06-AG-12

use ng_postcode::{api, client::Client, Postcode};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let key = std::env::var("NG_POSTCODE_API_KEY")?;
    let code: Postcode = std::env::args()
        .nth(1)
        .ok_or("usage: lookup <postcode>")?
        .parse()?;
    let found = Client::new(key).send(&api::lookup(code, 1)?)?;
    println!("{found:#?}");
    Ok(())
}