mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-06-17 16:16:37 +00:00
Refactor: Move Strategy
to binstalk-types
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
eba07fb147
commit
832a6c13ae
3 changed files with 65 additions and 26 deletions
|
@ -5,6 +5,7 @@
|
|||
use std::{borrow::Cow, collections::BTreeMap};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use strum_macros::{EnumCount, VariantArray};
|
||||
|
||||
mod package_formats;
|
||||
#[doc(inline)]
|
||||
|
@ -19,6 +20,41 @@ pub struct Meta {
|
|||
pub binstall: Option<PkgMeta>,
|
||||
}
|
||||
|
||||
/// Strategies to use for binary discovery
|
||||
#[derive(
|
||||
Debug,
|
||||
Copy,
|
||||
Clone,
|
||||
Eq,
|
||||
PartialEq,
|
||||
Ord,
|
||||
PartialOrd,
|
||||
EnumCount,
|
||||
VariantArray,
|
||||
Deserialize,
|
||||
Serialize,
|
||||
)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub enum Strategy {
|
||||
/// Attempt to download official pre-built artifacts using
|
||||
/// information provided in `Cargo.toml`.
|
||||
CrateMetaData,
|
||||
/// Query third-party QuickInstall for the crates.
|
||||
QuickInstall,
|
||||
/// Build the crates from source using `cargo-build`.
|
||||
Compile,
|
||||
}
|
||||
|
||||
impl Strategy {
|
||||
pub const fn to_str(self) -> &'static str {
|
||||
match self {
|
||||
Strategy::CrateMetaData => "crate-meta-data",
|
||||
Strategy::QuickInstall => "quick-install",
|
||||
Strategy::Compile => "compile",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Metadata for binary installation use.
|
||||
///
|
||||
/// Exposed via `[package.metadata]` in `Cargo.toml`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue