google-place-api 0.2.0

Rust fetch Google Places API, support both cli and crate
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use reqwest;
use reqwest::Url;
use serde::de::DeserializeOwned;

type Error = Box<dyn std::error::Error>;

pub async fn fetch<T>(url: &str, params: &[(impl AsRef<str>, impl AsRef<str>)]) -> Result<T, Error>
where
    T: DeserializeOwned,
{
    let url = Url::parse_with_params(url, params)?;

    let res = reqwest::get(url).await?;

    let output = res.json().await?;

    Ok(output)
}