Impl metafiles::binstall_v1::{Entry, Source}

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2022-07-26 22:29:10 +10:00
parent 93d4dbcd1a
commit 172af54cd8
No known key found for this signature in database
GPG key ID: 591C0B03040416D6
2 changed files with 68 additions and 14 deletions

View file

@ -2,3 +2,5 @@ mod cvs;
pub use cvs::*; pub use cvs::*;
pub mod v1; pub mod v1;
pub mod binstall_v1;

View file

@ -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,
},
}
}
} }
*/