Skip to main content

Crate ng_postcode

Crate ng_postcode 

Source
Expand description

Nigeria’s National Digital Alphanumeric Postcode (NDAPS), the building-level postcode issued by NIPOST.

The crate has a pure core and an optional shell:

  • Postcode parses, validates and formats codes offline.
  • api (feature api) describes the NIPOST API as plain data: requests to send and responses to decode, with no I/O.
  • client (feature client) is a small blocking HTTP client over api.
use ng_postcode::{Postcode, Segment};

let code: Postcode = "ek 01 a03 fk 01".parse()?;
assert_eq!(code.to_string(), "EK-01-A03-FK-01");
assert_eq!(code.as_str(), "EK01A03FK01");
assert_eq!(code.state(), "EK");
assert_eq!(code.prefix(Segment::Area), "EK-01-A03-FK");

Modules§

api
The NIPOST Postcode API as plain data: requests to send and responses to decode. Nothing here performs I/O, so it works with any HTTP client.
client
A blocking HTTP client: the only part of the crate that performs I/O.

Structs§

Corrected
The result of Postcode::parse_lenient.
Postcode
A well-formed postcode, held in its compact upper-case form.

Enums§

ParseError
Why a string is not a well-formed postcode.
Segment
The five segments of a postcode, AA-99-H77-BB-55, from widest to narrowest.

Functions§

is_valid
Whether input is a well-formed postcode.