1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
use restson::{Error, RestPath};

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Country {
    pub value: String,
    pub stationcount: String,
}

#[derive(Serialize, Deserialize, Debug)]
#[serde(untagged)]
pub enum CountryResponse {
    Countries(Vec<Country>),
    Country(Country),
}

impl RestPath<()> for CountryResponse {
    fn get_path(_: ()) -> Result<String, Error> {
        Ok(format!("webservice/json/countries"))
    }
}