mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-06-15 15:16:37 +00:00
35 lines
1,018 B
Rust
35 lines
1,018 B
Rust
use std::path::Path;
|
|
|
|
use log::info;
|
|
use reqwest::Method;
|
|
|
|
use super::Data;
|
|
use crate::{download, remote_exists, PkgFmt};
|
|
|
|
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
|
|
}
|
|
|
|
fn pkg_fmt(&self) -> PkgFmt {
|
|
PkgFmt::Tgz
|
|
}
|
|
}
|