pub struct Parse;Expand description
The Parser struct holds methods for parsing addresses.
Implementations§
Source§impl Parse
impl Parse
Sourcepub fn address_number(input: &str) -> IResult<&str, Option<i64>>
pub fn address_number(input: &str) -> IResult<&str, Option<i64>>
The address_number function expects one or more numeric digits, returned as an i64 value.
TODO: 2501-2503 address range should read as 2501 and discard remainder of range.
Sourcepub fn address_number_suffix(input: &str) -> IResult<&str, Option<&str>>
pub fn address_number_suffix(input: &str) -> IResult<&str, Option<&str>>
The parse_address_number_suffix function peeks at the next value in the input, checking if
the second character in the string is non-alphanumeric. Since address number suffixes in Grants Pass
take values of either 1/2 or 3/4, the second character will be /, which is not a valid
character for any components of the street name. So if a / is present, it must be an address
number suffix, and this function will parse and return it. If no address number suffix is
present, the function returns None.
Note this approach is not valid for address number suffixes that do not conform to the indicated pattern.
Sourcepub fn pre_directional(
input: &str,
) -> IResult<&str, Option<StreetNamePreDirectional>>
pub fn pre_directional( input: &str, ) -> IResult<&str, Option<StreetNamePreDirectional>>
The parse_pre_directional function attempts to parse the next word in the input to a
StreetNamePreDirectional. If a StreetNamePreDirectional is present, the function
returns the value and the remainder of the input. If not present, the function returns None
as the directional and gives the full input back.
Sourcepub fn pre_modifier(input: &str) -> IResult<&str, Option<StreetNamePreModifier>>
pub fn pre_modifier(input: &str) -> IResult<&str, Option<StreetNamePreModifier>>
The pre_modifier method attempts to parse the next word in the input as a
StreetNamePreModifier variant. Returns the full input in no pre-modifier is present.
Sourcepub fn pre_type(input: &str) -> IResult<&str, Option<StreetNamePreType>>
pub fn pre_type(input: &str) -> IResult<&str, Option<StreetNamePreType>>
The pre_type method attempts to parse the next word in the input as a
StreetNamePreType variant. Returns the full input if no pre-type is present.
Sourcepub fn separator(input: &str) -> IResult<&str, Option<StreetSeparator>>
pub fn separator(input: &str) -> IResult<&str, Option<StreetSeparator>>
The separator method attempts to parse the next word in the input as a
StreetSeparator variant. Returns the full input if no separator is present.
Sourcepub fn street_name(input: &str) -> IResult<&str, Option<String>>
pub fn street_name(input: &str) -> IResult<&str, Option<String>>
The street_name method attempts to parse the next sequence of words in the input as a
street name. After finding at least one word, will return if the next word in input is a
street name post type.
Screen for PO Boxes?
TODO: If no street name is present, but street type is present, this will categorize the
street type as a street name, because we do not check for post-type on the first pass.
Eg. West Street parses as directional: West, street name: Street. Should parse as
directional: None, street name: West, street type: Street.
TODO: Only checks for two post types in succession, but streets like Park Plaza Drive have
three.
Sourcepub fn post_type(input: &str) -> IResult<&str, Option<StreetNamePostType>>
pub fn post_type(input: &str) -> IResult<&str, Option<StreetNamePostType>>
The post_type function attempts to parse the next word in the input as a
StreetNamePostType value. Since the street name post type is a required field for Grants
Pass addresses, there is no need to peek and conditionally return. If the street name post
type evaluates to None, this is not a hard error, because the post type is not a required field
according to the FGDC standard, and partner agencies such as ECSO may have valid addresses
without a street name post type (e.g. “Broadway”).
Sourcepub fn is_post_type(input: &str) -> IResult<&str, bool>
pub fn is_post_type(input: &str) -> IResult<&str, bool>
The is_post_type function returns true if the input parses to a valid StreetNamePostType.
Peeks at the data without consuming it.
Sourcepub fn subaddress_type(input: &str) -> IResult<&str, Option<SubaddressType>>
pub fn subaddress_type(input: &str) -> IResult<&str, Option<SubaddressType>>
The subaddress_type function attempts to find a word following the street name post
type and preceding the postal community. If a word is present, and parses to a subaddress
type, the function will return the type and the remainder. If no subaddress type is present,
the function will return the full input.
Sourcepub fn subaddress_id(input: &str) -> IResult<&str, Option<String>>
pub fn subaddress_id(input: &str) -> IResult<&str, Option<String>>
The subaddress_id function attempts to find a word following the street name post
type and preceding the postal community. If a word is present, and parses to a subaddress
type, the function will return the type and the remainder. If no subaddress type is present,
the function will return the full input.
Sourcepub fn postal_community(input: &str) -> IResult<&str, Option<PostalCommunity>>
pub fn postal_community(input: &str) -> IResult<&str, Option<PostalCommunity>>
The postal_community function attempts to parse the next word in the input as a
PostalCommunity value.
Sourcepub fn is_postal_community(input: &str) -> IResult<&str, bool>
pub fn is_postal_community(input: &str) -> IResult<&str, bool>
The is_postal_community function returns true if the input parses to a valid PostalCommunity.
Peeks at the data without consuming it.
Sourcepub fn state(input: &str) -> IResult<&str, Option<State>>
pub fn state(input: &str) -> IResult<&str, Option<State>>
The state function attempts to parse the next word in the input as a
State value.
Sourcepub fn is_state(input: &str) -> IResult<&str, bool>
pub fn is_state(input: &str) -> IResult<&str, bool>
The is_state function returns true if the input parses to a valid State.
Peeks at the data without consuming it.
Sourcepub fn zip(input: &str) -> IResult<&str, Option<i64>>
pub fn zip(input: &str) -> IResult<&str, Option<i64>>
The zip function attempts to parse the next word in the input as a
postal zip code.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Parse
impl RefUnwindSafe for Parse
impl Send for Parse
impl Sync for Parse
impl Unpin for Parse
impl UnwindSafe for Parse
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more