Skip to main content

easy_install/
artifact.rs

1use serde::Deserialize;
2use std::hash::Hash;
3use std::{collections::HashSet, hash::Hasher};
4#[derive(Eq, Deserialize, Debug)]
5pub(crate) struct GhArtifact {
6    pub(crate) name: String,
7    pub(crate) browser_download_url: String,
8}
9
10// Manually implement PartialEq and Hash to ensure it will always produce the
11// same hash as a str with the same content, and that the comparison will be
12// the same to coparing a string.
13
14impl PartialEq for GhArtifact {
15    fn eq(&self, other: &Self) -> bool {
16        self.name.eq(&other.name)
17    }
18}
19
20impl Hash for GhArtifact {
21    fn hash<H>(&self, state: &mut H)
22    where
23        H: Hasher,
24    {
25        let s: &str = self.name.as_str();
26        s.hash(state)
27    }
28}
29
30#[derive(Debug, Default, Deserialize)]
31pub(crate) struct GhArtifacts {
32    pub(crate) assets: HashSet<GhArtifact>,
33}