mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-06-16 07:36:38 +00:00
Refactor fetch and install to be more self-contained
This commit is contained in:
parent
81cf2fc526
commit
b584038d0d
8 changed files with 268 additions and 116 deletions
30
src/fetchers.rs
Normal file
30
src/fetchers.rs
Normal file
|
@ -0,0 +1,30 @@
|
|||
use std::path::Path;
|
||||
|
||||
pub use gh_release::*;
|
||||
|
||||
use crate::PkgMeta;
|
||||
|
||||
mod gh_release;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
pub trait Fetcher {
|
||||
/// Create a new fetcher from some data
|
||||
async fn new(data: &Data) -> Result<Self, anyhow::Error>
|
||||
where
|
||||
Self: std::marker::Sized;
|
||||
|
||||
/// Fetch a package
|
||||
async fn fetch(&self, dst: &Path) -> Result<(), anyhow::Error>;
|
||||
|
||||
/// Check if a package is available for download
|
||||
async fn check(&self) -> Result<bool, anyhow::Error>;
|
||||
}
|
||||
|
||||
/// Data required to fetch a package
|
||||
pub struct Data {
|
||||
pub name: String,
|
||||
pub target: String,
|
||||
pub version: String,
|
||||
pub repo: Option<String>,
|
||||
pub meta: PkgMeta,
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue