fork of https://github.com/rustwasm/wasm-pack for the needs of NextGraph.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
wasm-pack/src/install/krate.rs

24 lines
597 B

use install::Tool;
use serde::Deserialize;
#[derive(Debug, Deserialize)]
pub struct Krate {
pub max_version: String,
}
#[derive(Debug, Deserialize)]
pub struct KrateResponse {
#[serde(rename = "crate")]
pub krate: Krate,
}
impl Krate {
pub fn new(name: &Tool) -> Result<Krate, failure::Error> {
let krate_address = format!("https://crates.io/api/v1/crates/{}", name);
let client = reqwest::Client::new();
let mut res = client.get(&krate_address).send()?;
let kr: KrateResponse = serde_json::from_str(&res.text()?)?;
Ok(kr.krate)
}
}