Struct Parse

Source
pub struct Parse;
Expand description

The Parser struct holds methods for parsing addresses.

Implementations§

Source§

impl Parse

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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”).

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn is_zip(input: &str) -> IResult<&str, bool>

The is_zip function returns true if the input parses to a valid zip code. Peeks at the data without consuming it.

Source

pub fn address(input: &str) -> IResult<&str, PartialAddress>

The address function attempts to read the complete address and parse it into its constituent components.

Trait Implementations§

Source§

impl Clone for Parse

Source§

fn clone(&self) -> Parse

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Parse

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Copy for Parse

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more