-
Notifications
You must be signed in to change notification settings - Fork 760
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic hash More notes Looking at cache...
- Loading branch information
1 parent
3aa2378
commit b1e9f80
Showing
56 changed files
with
2,593 additions
and
465 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use pypi_types::HashDigest; | ||
|
||
pub trait Hashed { | ||
/// Return the [`HashDigest`]s for the archive. | ||
fn hashes(&self) -> &[HashDigest]; | ||
|
||
/// Returns `true` if the archive satisfies the given hashes. | ||
fn satisfies(&self, hashes: &[HashDigest]) -> bool { | ||
if hashes.is_empty() { | ||
true | ||
} else { | ||
self.hashes().iter().any(|hash| hashes.contains(hash)) | ||
} | ||
} | ||
|
||
/// Returns `true` if the archive includes a hash for at least one of the given algorithms. | ||
fn has_digests(&self, hashes: &[HashDigest]) -> bool { | ||
if hashes.is_empty() { | ||
true | ||
} else { | ||
hashes | ||
.iter() | ||
.map(HashDigest::algorithm) | ||
.any(|algorithm| self.hashes().iter().any(|hash| hash.algorithm == algorithm)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.