mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 21:35:00 +00:00
Replace PyPI-internal Hashes representation with flat vector (#2925)
## Summary Right now, we have a `Hashes` representation that looks like: ```rust /// A dictionary mapping a hash name to a hex encoded digest of the file. /// /// PEP 691 says multiple hashes can be included and the interpretation is left to the client. #[derive(Debug, Clone, Eq, PartialEq, Default, Deserialize)] pub struct Hashes { pub md5: Option<Box<str>>, pub sha256: Option<Box<str>>, pub sha384: Option<Box<str>>, pub sha512: Option<Box<str>>, } ``` It stems from the PyPI API, which returns a dictionary of hashes. We tend to pass these around as a vector of `Vec<Hashes>`. But it's a bit strange because each entry in that vector could contain multiple hashes. And it makes it difficult to ask questions like "Is `sha256:ab21378ca980a8` in the set of hashes"? This PR instead treats `Hashes` as the PyPI-internal type, and uses a new `Vec<HashDigest>` everywhere in our own APIs.
This commit is contained in:
parent
1512e07a2e
commit
13ae5ac8dc
10 changed files with 195 additions and 103 deletions
|
@ -598,7 +598,7 @@ impl CacheBucket {
|
|||
Self::FlatIndex => "flat-index-v0",
|
||||
Self::Git => "git-v0",
|
||||
Self::Interpreter => "interpreter-v0",
|
||||
Self::Simple => "simple-v6",
|
||||
Self::Simple => "simple-v7",
|
||||
Self::Wheels => "wheels-v0",
|
||||
Self::Archive => "archive-v0",
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue