pub struct Postcode(/* private fields */);Expand description
A well-formed postcode, held in its compact upper-case form.
Well formed is not the same as assigned: only the NIPOST API knows whether a code belongs to a real building.
Implementations§
Source§impl Postcode
impl Postcode
Sourcepub fn parse(input: &str) -> Result<Self, ParseError>
pub fn parse(input: &str) -> Result<Self, ParseError>
Parses a hyphenated, spaced or compact code in either case.
Sourcepub fn parse_lenient(input: &str) -> Result<Corrected, ParseError>
pub fn parse_lenient(input: &str) -> Result<Corrected, ParseError>
Parses like parse after swapping look-alike characters
that cannot occur where they stand: 0 1 5 8 for O I S B where a
letter is required, and the reverse (plus L for 1) where a digit is.
The result is well formed but may not be the code the user meant, so
confirm it with them when corrections is not zero.
Sourcepub fn from_segments(
state: &str,
lga: &str,
district: &str,
area: &str,
unit: &str,
) -> Result<Self, ParseError>
pub fn from_segments( state: &str, lga: &str, district: &str, area: &str, unit: &str, ) -> Result<Self, ParseError>
Builds a code from its segments, zero-filling the LGA and unit so that
"1" becomes "01".
Sourcepub fn prefix(&self, through: Segment) -> String
pub fn prefix(&self, through: Segment) -> String
The hyphenated code down to and including through, so
prefix(Segment::Area) is EK-01-A03-FK.
Sourcepub fn truncate(&self, through: Segment) -> Prefix
pub fn truncate(&self, through: Segment) -> Prefix
The code cut off after through, as a value: truncate(Segment::Area) is the
area this building is in.
pub fn segment(&self, segment: Segment) -> &str
pub fn state(&self) -> &str
pub fn lga(&self) -> &str
pub fn district(&self) -> &str
pub fn area(&self) -> &str
pub fn unit(&self) -> &str
Trait Implementations§
impl Copy for Postcode
Source§impl<'de> Deserialize<'de> for Postcode
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Postcode
serde only.