swapi/types/
people.rs

1#[derive(Debug, Deserialize, Default)]
2pub struct People {
3    name: String,
4    birth_year: String,
5    eye_color: String,
6    gender: String,
7    hair_color: String,
8    height: String,
9    mass: String,
10    skin_color: String,
11    homeworld: String,
12    films: Vec<String>,
13    species: Vec<String>,
14    starships: Vec<String>,
15    vehicles: Vec<String>,
16    url: String,
17    created: String,
18    edited: String,
19}
20
21pub fn query_people(people_num: &str) {
22    // Base URL for a people request
23    let base_url: String = "/people/".to_owned();
24    let people_url: &str = &(base_url + &people_num);
25
26    let results = super::query::api_query(people_url);
27    match results {
28        Ok(mut r) => println!("{:#?}", r.json::<People>()),
29        Err(e) => println!("{:#?}", e),
30    }
31}