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.
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
Available on crate feature
serde only.Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Postcode
Source§impl Ord for Postcode
impl Ord for Postcode
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for Postcode
impl PartialOrd for Postcode
impl StructuralPartialEq for Postcode
Auto Trait Implementations§
impl Freeze for Postcode
impl RefUnwindSafe for Postcode
impl Send for Postcode
impl Sync for Postcode
impl Unpin for Postcode
impl UnsafeUnpin for Postcode
impl UnwindSafe for Postcode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more