[][src]Struct address_formatter::Formatter

pub struct Formatter { /* fields omitted */ }

This Formatter holds all the configuration needed to format a Place to a nice text.

The main method is the format method, that takes a Place or something that can be converted to a Place and return a result with the formatted String

   use address_formatter::Component::*;
   let formatter = address_formatter::Formatter::default();

   let addr: address_formatter::Place = hashmap!(
       City => "Toulouse",
       Country => "France",
       CountryCode => "FR",
       County => "Toulouse",
       HouseNumber => "17",
       Neighbourhood => "Lafourguette",
       Postcode => "31000",
       Road => "Rue du Médecin-Colonel Calbairac",
       State => "Midi-Pyrénées",
       Suburb => "Toulouse Ouest",
   ).into();

   assert_eq!(
       formatter.format(addr).unwrap(),
       r#"17 Rue du Médecin-Colonel Calbairac
31000 Toulouse
France
"#
       .to_owned()
   )

Methods

impl Formatter[src]

pub fn format(&self, into_addr: impl Into<Place>) -> Result<String, Error>[src]

make a human readable text from a Place

   use address_formatter::Component::*;
   let formatter = address_formatter::Formatter::default();

   let addr: address_formatter::Place = hashmap!(
       City => "Toulouse",
       Country => "France",
       CountryCode => "FR",
       County => "Toulouse",
       HouseNumber => "17",
       Neighbourhood => "Lafourguette",
       Postcode => "31000",
       Road => "Rue du Médecin-Colonel Calbairac",
       State => "Midi-Pyrénées",
       Suburb => "Toulouse Ouest",
   ).into();

   assert_eq!(
       formatter.format(addr).unwrap(),
       r#"17 Rue du Médecin-Colonel Calbairac
31000 Toulouse
France
"#
       .to_owned()
   )

pub fn format_with_config(
    &self,
    into_addr: impl Into<Place>,
    conf: Configuration
) -> Result<String, Error>
[src]

make a human readable text from a Place Same as the format method, but with a Configuration object

Trait Implementations

impl Default for Formatter[src]

fn default() -> Self[src]

Default constructor

Auto Trait Implementations

impl Send for Formatter

impl Sync for Formatter

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]