Struct rustpostal::address::AddressParserOptions
source · [−]pub struct AddressParserOptions { /* private fields */ }
Expand description
Parsing options.
Implementations
sourceimpl AddressParserOptions
impl AddressParserOptions
sourcepub fn new(
language: Option<&str>,
country: Option<&str>
) -> Result<AddressParserOptions, NulError>
pub fn new(
language: Option<&str>,
country: Option<&str>
) -> Result<AddressParserOptions, NulError>
Create options for the address parser.
Examples
use rustpostal::address;
fn main() -> Result<(), std::ffi::NulError> {
let options = address::AddressParserOptions::new(Some("en"), Some("en"))?;
Ok(())
}
sourcepub fn parse<'b>(
&self,
address: &'b str
) -> Result<AddressParserResponse, NulError>
pub fn parse<'b>(
&self,
address: &'b str
) -> Result<AddressParserResponse, NulError>
Parse a postal address and derive labeled tokens using libpostal
.
Examples
use rustpostal::error::RuntimeError;
use rustpostal::{address, LibModules};
fn main() -> Result<(), RuntimeError> {
let postal_module = LibModules::Address;
postal_module.setup()?;
let options = address::AddressParserOptions::new(None, None)?;
let address = "St Johns Centre, Rope Walk, Bedford, Bedfordshire, MK42 0XE, United Kingdom";
let labels_tokens = options.parse(address)?;
for (label, token) in &labels_tokens {
println!("{}: {}", label, token);
}
Ok(())
}
Errors
It will return an error if the address contains an internal null byte.
Trait Implementations
sourceimpl Clone for AddressParserOptions
impl Clone for AddressParserOptions
sourcefn clone(&self) -> AddressParserOptions
fn clone(&self) -> AddressParserOptions
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for AddressParserOptions
impl Debug for AddressParserOptions
sourceimpl Default for AddressParserOptions
impl Default for AddressParserOptions
sourcefn default() -> AddressParserOptions
fn default() -> AddressParserOptions
Returns the “default value” for a type. Read more
sourceimpl Hash for AddressParserOptions
impl Hash for AddressParserOptions
sourceimpl Ord for AddressParserOptions
impl Ord for AddressParserOptions
sourceimpl PartialEq<AddressParserOptions> for AddressParserOptions
impl PartialEq<AddressParserOptions> for AddressParserOptions
sourcefn eq(&self, other: &AddressParserOptions) -> bool
fn eq(&self, other: &AddressParserOptions) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &AddressParserOptions) -> bool
fn ne(&self, other: &AddressParserOptions) -> bool
This method tests for !=
.
sourceimpl PartialOrd<AddressParserOptions> for AddressParserOptions
impl PartialOrd<AddressParserOptions> for AddressParserOptions
sourcefn partial_cmp(&self, other: &AddressParserOptions) -> Option<Ordering>
fn partial_cmp(&self, other: &AddressParserOptions) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Eq for AddressParserOptions
impl StructuralEq for AddressParserOptions
impl StructuralPartialEq for AddressParserOptions
Auto Trait Implementations
impl RefUnwindSafe for AddressParserOptions
impl Send for AddressParserOptions
impl Sync for AddressParserOptions
impl Unpin for AddressParserOptions
impl UnwindSafe for AddressParserOptions
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more