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 use cvs::*;
|
||||||
|
|
||||||
pub mod v1;
|
pub mod v1;
|
||||||
|
|
||||||
|
pub mod binstall_v1;
|
||||||
|
|
|
@ -1,15 +1,67 @@
|
||||||
/*
|
use compact_str::CompactString;
|
||||||
{
|
use semver::Version;
|
||||||
"name": "cargo-binstall",
|
use serde::{Deserialize, Serialize};
|
||||||
"version_req": none,
|
use url::Url;
|
||||||
"current_version": "0.10.0"
|
|
||||||
"source": {
|
use crate::binstall::MetaData;
|
||||||
"type": "Registry",
|
|
||||||
"url": "https://crates.io",
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
},
|
pub struct Entry {
|
||||||
"target": none,
|
pub name: CompactString,
|
||||||
"bins": [
|
pub version_req: CompactString,
|
||||||
"cargo-binstall",
|
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