geocode 0.1.1

Find location information by using Google Maps or DataScienceToolkit API
Documentation
use serde_json;
use std;
use google::{
    GoogleResponse,
    STATUS_NO_RESULTS,
    STATUS_OK,
    STATUS_OVER_LIMIT,
    ERR_OVER_LIMIT,
    ERR_NO_RESULTS,
};

#[derive(Deserialize, Debug, Clone)]
struct NominatimResponse{
    pub results: Vec<NominatimResponseResult>
}

#[derive(Deserialize, Debug, Clone)]
pub struct NominatimResponseResult {
    pub display_name: String,
    pub lat: String,
    pub lon: String,
    pub class: String,

}
use url::Url;
use structs::*;
use cabot::{RequestBuilder, Client};

pub const BASE_URL: &str = "http://nominatim.openstreetmap.org/search/";
pub fn geocode(address: &str) -> Result<GeocodeResponse, String> {
    let mut url = Url::parse(BASE_URL).unwrap();
    url.query_pairs_mut().append_pair("format", "json");
    url.query_pairs_mut().append_pair("q", address);
    url.query_pairs_mut().append_pair("addressdetails", "1");
    url.query_pairs_mut().append_pair("limit", "1");
    url.query_pairs_mut().append_pair("polygon_text", "1");
    let request = RequestBuilder::new(url.as_str())
        .set_http_method("GET")
        .build()
        .unwrap();
    let client = Client::new();
    let raw_response = client.execute(&request).unwrap();
    println!("{:?}", url);
    println!("{:?}", std::str::from_utf8(&raw_response.body().unwrap()));
    let response: NominatimResponse = serde_json::from_slice(
	    	raw_response.body().unwrap()
	    )
	    .unwrap();
    println!("{:?}", raw_response);
    return match response.results.len() {
        1 => Ok(GeocodeResponse {
            location: Location{
                lat: response.results[0].clone().lat.parse::<f64>().unwrap(),
                lng: response.results[0].clone().lon.parse::<f64>().unwrap(),
            },
            location_type: response.results[0].clone().class,
            formatted_address: response.results[0].clone().display_name,
        }),
        0 => Err(ERR_NO_RESULTS.to_string()),
        _ => Err(ERR_NO_RESULTS.to_string()),
    };
}