us_address_parser/parse/
mod.rs

1use direction::parse_direction;
2use street::{parse_street_name, parse_street_no};
3use street_type::parse_street_type;
4use unit::parse_unit_type_and_no;
5
6use crate::Address;
7
8pub(crate) mod direction;
9pub(crate) mod street;
10pub(crate) mod street_type;
11pub(crate) mod unit;
12
13impl Address {
14    /// Gets the street number for an address
15    pub fn street_no(self) -> Self {
16        parse_street_no(self)
17    }
18
19    /// Matches an input address to a list of 748 U.S. street types (half of them are abbreviated, other half are full types) to parse out the street type
20    pub fn street_type(self) -> Self {
21        parse_street_type(self)
22    }
23
24    /// Matches an input address to a list of 48 unit types (half of them are abbreviated, other half are full types) to parse out the unit type and unit number
25    pub fn unit_type_and_no(self) -> Self {
26        parse_unit_type_and_no(self)
27    }
28
29    /// Finds the pre or post direction in an input address
30    pub fn directional(self) -> Self {
31        parse_direction(self)
32    }
33
34    /// Uses the [`Address::street_no()`], [`Address::street_type()`], [`Address::unit_type_and_no()`], and [`Address::directional()`]
35    /// to strip out those parts of an input address to get the street name.
36    /// !!!USE LAST!!! when adding methods to [`Address`].
37    /// ```no_run
38    /// address
39    ///    .street_no(&full_address)
40    ///    .directional(&full_address)
41    ///    .street_type(&full_address)
42    ///    .unit_type_and_no(&full_address)
43    ///    .street_name(&full_address)
44    /// ```
45    pub fn street_name(self) -> Self {
46        parse_street_name(self)
47    }
48}