diff options
| author | Teddy Wing | 2021-05-29 14:39:29 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2021-05-29 14:39:29 +0200 | 
| commit | 1a9a3ecf18cd71898be230e2045b2d907f8fcdd7 (patch) | |
| tree | 5bbd6363aa0671fb3326b30ca5f349d12e9e8091 /src | |
| parent | a1f45240d3d0353028fc429175479adce5a15b2d (diff) | |
| download | reflectub-1a9a3ecf18cd71898be230e2045b2d907f8fcdd7.tar.bz2 | |
Parse GitHub API response to a struct
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.rs | 15 | 
1 files changed, 15 insertions, 0 deletions
| diff --git a/src/main.rs b/src/main.rs index 5edbf17..14d5f4d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@  use reqwest::blocking::ClientBuilder; +use serde::Deserialize;  const USER_AGENT: &'static str = concat!( @@ -8,6 +9,18 @@ const USER_AGENT: &'static str = concat!(  ); +#[derive(Debug, Deserialize)] +struct Repo { +    id: usize, +    name: String, +    description: Option<String>, +    fork: bool, +    git_url: String, +    default_branch: String, +    updated_at: String,  // TODO: Maybe parse to date? +} + +  fn main() {      let mut headers = reqwest::header::HeaderMap::new();      headers.insert("Accept", "application/vnd.github.v3+json".parse().unwrap()); @@ -26,6 +39,8 @@ fn main() {          ),      )          .send() +        .unwrap() +        .json::<Vec<Repo>>()          .unwrap();      dbg!(&response); | 
