mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-22 21:48:42 +00:00
Add Fetcher::target
to trait Fetcher
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
603955b848
commit
3f2e03893a
3 changed files with 14 additions and 1 deletions
|
@ -30,6 +30,9 @@ pub trait Fetcher {
|
|||
|
||||
/// Should return true if the remote is from a third-party source
|
||||
fn is_third_party(&self) -> bool;
|
||||
|
||||
/// Return the target for this fetcher
|
||||
fn target(&self) -> &str;
|
||||
}
|
||||
|
||||
/// Data required to fetch a package
|
||||
|
|
|
@ -66,6 +66,10 @@ impl super::Fetcher for GhCrateMeta {
|
|||
fn is_third_party(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn target(&self) -> &str {
|
||||
&self.data.target
|
||||
}
|
||||
}
|
||||
|
||||
/// Template for constructing download paths
|
||||
|
|
|
@ -13,6 +13,7 @@ const USER_AGENT: &str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VE
|
|||
|
||||
pub struct QuickInstall {
|
||||
package: String,
|
||||
target: String,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
|
@ -20,9 +21,10 @@ impl super::Fetcher for QuickInstall {
|
|||
async fn new(data: &Data) -> Box<Self> {
|
||||
let crate_name = &data.name;
|
||||
let version = &data.version;
|
||||
let target = &data.target;
|
||||
let target = data.target.clone();
|
||||
Box::new(Self {
|
||||
package: format!("{crate_name}-{version}-{target}"),
|
||||
target,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -50,6 +52,10 @@ impl super::Fetcher for QuickInstall {
|
|||
fn is_third_party(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn target(&self) -> &str {
|
||||
&self.target
|
||||
}
|
||||
}
|
||||
|
||||
impl QuickInstall {
|
||||
|
|
Loading…
Add table
Reference in a new issue