sbom_walker/model/
metadata.rs

1use url::Url;
2
3#[derive(Clone, Debug, PartialEq, Eq, serde::Deserialize, serde::Serialize)]
4pub struct Key {
5    #[serde(default, skip_serializing_if = "Option::is_none")]
6    pub fingerprint: Option<String>,
7    pub url: Url,
8}
9
10impl From<Url> for Key {
11    fn from(value: Url) -> Self {
12        let fingerprint = value.fragment().map(ToString::to_string);
13        Self {
14            url: value,
15            fingerprint,
16        }
17    }
18}
19
20#[derive(Clone, Debug, PartialEq, Eq, serde::Deserialize, serde::Serialize)]
21pub struct SourceMetadata {
22    #[serde(default, skip_serializing_if = "Vec::is_empty")]
23    pub keys: Vec<Key>,
24}
25
26impl<'a> From<&'a Key> for walker_common::validate::source::Key<'a> {
27    fn from(value: &'a Key) -> Self {
28        walker_common::validate::source::Key {
29            fingerprint: value.fingerprint.as_deref(),
30            url: &value.url,
31        }
32    }
33}