Refactor and add new enum PkgFmtDecomposed

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2022-06-11 18:40:21 +10:00
parent c33f195d5f
commit bd68613448
No known key found for this signature in database
GPG key ID: 591C0B03040416D6
3 changed files with 78 additions and 29 deletions

View file

@ -1,7 +1,6 @@
use std::collections::HashMap;
use serde::{Deserialize, Serialize};
use strum_macros::{Display, EnumString, EnumVariantNames};
pub mod drivers;
pub use drivers::*;
@ -18,6 +17,9 @@ pub mod fetchers;
mod target;
pub use target::*;
mod fmt;
pub use fmt::*;
/// Default package path template (may be overridden in package Cargo.toml)
pub const DEFAULT_PKG_URL: &str =
"{ repo }/releases/download/v{ version }/{ name }-{ target }-v{ version }.{ archive-format }";
@ -25,33 +27,6 @@ pub const DEFAULT_PKG_URL: &str =
/// Default binary name template (may be overridden in package Cargo.toml)
pub const DEFAULT_BIN_DIR: &str = "{ name }-{ target }-v{ version }/{ bin }{ binary-ext }";
/// Binary format enumeration
#[derive(
Debug, Copy, Clone, PartialEq, Serialize, Deserialize, Display, EnumString, EnumVariantNames,
)]
#[strum(serialize_all = "snake_case")]
#[serde(rename_all = "snake_case")]
pub enum PkgFmt {
/// Download format is TAR (uncompressed)
Tar,
/// Download format is TGZ (TAR + GZip)
Tgz,
/// Download format is TAR + XZ
Txz,
/// Download format is TAR + Zstd
Tzstd,
/// Download format is Zip
Zip,
/// Download format is raw / binary
Bin,
}
impl Default for PkgFmt {
fn default() -> Self {
Self::Tgz
}
}
/// `binstall` metadata container
///
/// Required to nest metadata under `package.metadata.binstall`