From 5ca1278c2228efcee0eb3b879c75fd26abc270a3 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Wed, 27 Jul 2022 19:18:44 +1000 Subject: [PATCH] Add new enum `binstall_v1::SourceType` Use it to represent source type instead of using `CompactString`. Signed-off-by: Jiahao XU --- src/metafiles/binstall_v1.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/metafiles/binstall_v1.rs b/src/metafiles/binstall_v1.rs index 386b2929..9704719f 100644 --- a/src/metafiles/binstall_v1.rs +++ b/src/metafiles/binstall_v1.rs @@ -48,9 +48,16 @@ impl MetaData { } } +#[derive(Debug, Copy, Clone, Serialize, Deserialize)] +enum SourceType { + Git, + Path, + Registry, +} + #[derive(Debug, Serialize, Deserialize)] pub struct Source { - source_type: CompactString, + source_type: SourceType, url: Url, } @@ -60,15 +67,15 @@ impl From for Source { match src { Git(url) => Source { - source_type: "Git".into(), + source_type: SourceType::Git, url, }, Path(url) => Source { - source_type: "Path".into(), + source_type: SourceType::Path, url, }, Registry(url) => Source { - source_type: "Registry".into(), + source_type: SourceType::Registry, url, }, }