mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-06-16 23:56:37 +00:00
Add quickinstall support
This commit is contained in:
parent
b584038d0d
commit
4e0ca0c1c3
5 changed files with 75 additions and 18 deletions
31
src/fetchers/quickinstall.rs
Normal file
31
src/fetchers/quickinstall.rs
Normal file
|
@ -0,0 +1,31 @@
|
|||
use std::path::Path;
|
||||
|
||||
use log::info;
|
||||
use reqwest::Method;
|
||||
|
||||
use crate::{download, remote_exists};
|
||||
use super::Data;
|
||||
|
||||
pub struct QuickInstall {
|
||||
url: String,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl super::Fetcher for QuickInstall {
|
||||
async fn new(data: &Data) -> Result<Box<Self>, anyhow::Error> {
|
||||
let crate_name = &data.name;
|
||||
let version = &data.version;
|
||||
let target = &data.target;
|
||||
Ok(Box::new(Self { url: format!("https://github.com/alsuren/cargo-quickinstall/releases/download/{crate_name}-{version}-{target}/{crate_name}-{version}-{target}.tar.gz") }))
|
||||
}
|
||||
|
||||
async fn check(&self) -> Result<bool, anyhow::Error> {
|
||||
info!("Checking for package at: '{}'", self.url);
|
||||
remote_exists(&self.url, Method::OPTIONS).await
|
||||
}
|
||||
|
||||
async fn fetch(&self, dst: &Path) -> Result<(), anyhow::Error> {
|
||||
info!("Downloading package from: '{}'", self.url);
|
||||
download(&self.url, dst).await
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue