aiken new: Try to get the latest tag of stdlib

This commit is contained in:
Ariady Putra
2023-08-17 02:19:54 +07:00
committed by Lucas
parent c95f43ae07
commit 8cf92ce8ed
5 changed files with 30 additions and 3 deletions

View File

@@ -0,0 +1 @@
pub mod repo;

View File

@@ -0,0 +1,22 @@
use reqwest::{blocking::Client, header::USER_AGENT, Error};
use serde::Deserialize;
#[derive(Deserialize)]
pub struct LatestRelease {
pub tag_name: String,
}
impl LatestRelease {
pub fn of<Repo: AsRef<str>>(repo: Repo) -> Result<Self, Error> {
Ok({
Client::new()
.get(format!(
"https://api.github.com/repos/{}/releases/latest",
repo.as_ref()
))
.header(USER_AGENT, "aiken")
.send()?
.json::<Self>()?
})
}
}