mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-21 13:08:42 +00:00
Impl metafiles::binstall_v1::{Entry, Source}
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
93d4dbcd1a
commit
172af54cd8
2 changed files with 68 additions and 14 deletions
|
@ -2,3 +2,5 @@ mod cvs;
|
|||
pub use cvs::*;
|
||||
|
||||
pub mod v1;
|
||||
|
||||
pub mod binstall_v1;
|
||||
|
|
|
@ -1,15 +1,67 @@
|
|||
/*
|
||||
{
|
||||
"name": "cargo-binstall",
|
||||
"version_req": none,
|
||||
"current_version": "0.10.0"
|
||||
"source": {
|
||||
"type": "Registry",
|
||||
"url": "https://crates.io",
|
||||
},
|
||||
"target": none,
|
||||
"bins": [
|
||||
"cargo-binstall",
|
||||
],
|
||||
use compact_str::CompactString;
|
||||
use semver::Version;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
use crate::binstall::MetaData;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Entry {
|
||||
pub name: CompactString,
|
||||
pub version_req: CompactString,
|
||||
pub current_version: Version,
|
||||
pub source: Source,
|
||||
pub target: CompactString,
|
||||
pub bins: Vec<CompactString>,
|
||||
}
|
||||
impl Entry {
|
||||
pub fn new(metadata: MetaData) -> Self {
|
||||
let MetaData {
|
||||
bins,
|
||||
cvs:
|
||||
super::CrateVersionSource {
|
||||
name,
|
||||
version,
|
||||
source,
|
||||
},
|
||||
version_req,
|
||||
target,
|
||||
} = metadata;
|
||||
|
||||
Self {
|
||||
name: name.into(),
|
||||
version_req: version_req.into(),
|
||||
current_version: version,
|
||||
source: source.into(),
|
||||
target: target.into(),
|
||||
bins,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Source {
|
||||
source_type: CompactString,
|
||||
url: Url,
|
||||
}
|
||||
|
||||
impl From<super::Source> for Source {
|
||||
fn from(src: super::Source) -> Self {
|
||||
use super::Source::*;
|
||||
|
||||
match src {
|
||||
Git(url) => Source {
|
||||
source_type: "Git".into(),
|
||||
url,
|
||||
},
|
||||
Path(url) => Source {
|
||||
source_type: "Path".into(),
|
||||
url,
|
||||
},
|
||||
Registry(url) => Source {
|
||||
source_type: "Registry".into(),
|
||||
url,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue