aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock15
-rw-r--r--Cargo.toml1
-rw-r--r--src/main.rs15
3 files changed, 31 insertions, 0 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 7f42806..250509e 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -564,6 +564,7 @@ name = "reflectub"
version = "0.0.1"
dependencies = [
"reqwest",
+ "serde",
]
[[package]]
@@ -654,6 +655,20 @@ name = "serde"
version = "1.0.126"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec7505abeacaec74ae4778d9d9328fe5a5d04253220a85c4ee022239fc996d03"
+dependencies = [
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_derive"
+version = "1.0.126"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "963a7dbc9895aeac7ac90e74f34a5d5261828f79df35cbed41e10189d3804d43"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
[[package]]
name = "serde_json"
diff --git a/Cargo.toml b/Cargo.toml
index 11605d9..3387fb1 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,3 +5,4 @@ edition = "2018"
[dependencies]
reqwest = { version = "0.11.3", features = ["blocking", "json"] }
+serde = { version = "1.0.126", features = ["derive"] }
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);