ng_postcode/lib.rs
1//! Nigeria's National Digital Alphanumeric Postcode (NDAPS), the
2//! building-level postcode issued by NIPOST.
3//!
4//! The crate has a pure core and an optional shell:
5//!
6//! - [`Postcode`] parses, validates and formats codes offline.
7//! - [`api`] (feature `api`) describes the NIPOST API as plain data: requests
8//! to send and responses to decode, with no I/O.
9//! - [`client`] (feature `client`) is a small blocking HTTP client over `api`.
10//!
11//! ```
12//! use ng_postcode::{Postcode, Segment};
13//!
14//! let code: Postcode = "ek 01 a03 fk 01".parse()?;
15//! assert_eq!(code.to_string(), "EK-01-A03-FK-01");
16//! assert_eq!(code.as_str(), "EK01A03FK01");
17//! assert_eq!(code.state(), "EK");
18//! assert_eq!(code.prefix(Segment::Area), "EK-01-A03-FK");
19//! # Ok::<(), ng_postcode::ParseError>(())
20//! ```
21
22mod postcode;
23
24#[cfg(feature = "api")]
25pub mod api;
26#[cfg(feature = "client")]
27pub mod client;
28
29pub use postcode::{is_valid, Corrected, ParseError, Postcode, Segment};