Add new enum binstall_v1::SourceType

Use it to represent source type instead of using `CompactString`.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2022-07-27 19:18:44 +10:00
parent cbd64b039d
commit 5ca1278c22
No known key found for this signature in database
GPG key ID: 591C0B03040416D6

View file

@ -48,9 +48,16 @@ impl MetaData {
} }
} }
#[derive(Debug, Copy, Clone, Serialize, Deserialize)]
enum SourceType {
Git,
Path,
Registry,
}
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
pub struct Source { pub struct Source {
source_type: CompactString, source_type: SourceType,
url: Url, url: Url,
} }
@ -60,15 +67,15 @@ impl From<super::Source> for Source {
match src { match src {
Git(url) => Source { Git(url) => Source {
source_type: "Git".into(), source_type: SourceType::Git,
url, url,
}, },
Path(url) => Source { Path(url) => Source {
source_type: "Path".into(), source_type: SourceType::Path,
url, url,
}, },
Registry(url) => Source { Registry(url) => Source {
source_type: "Registry".into(), source_type: SourceType::Registry,
url, url,
}, },
} }