csaf_walker/report/
mod.rs

1//! Reporting functionality
2
3mod render;
4
5pub use render::*;
6
7use crate::discover::DiscoveredAdvisory;
8use std::borrow::Cow;
9use std::collections::{BTreeMap, HashSet};
10use url::Url;
11use walker_common::utils::url::Urlify;
12
13#[derive(Clone, Debug)]
14pub struct ReportResult<'d> {
15    pub total: usize,
16    pub duplicates: &'d Duplicates,
17    pub errors: &'d BTreeMap<DocumentKey, String>,
18    pub warnings: &'d BTreeMap<DocumentKey, Vec<Cow<'static, str>>>,
19}
20
21#[derive(Clone, Debug, Default)]
22pub struct Duplicates {
23    pub duplicates: BTreeMap<DocumentKey, usize>,
24    pub known: HashSet<DocumentKey>,
25}
26
27#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
28pub struct DocumentKey {
29    /// the URL to the distribution folder
30    pub distribution_url: Url,
31    /// the URL to the document, relative to the `distribution_url`.
32    pub url: String,
33}
34
35impl DocumentKey {
36    pub fn for_document(advisory: &DiscoveredAdvisory) -> Self {
37        Self {
38            distribution_url: advisory.url.clone(),
39            url: advisory.possibly_relative_url(),
40        }
41    }
42}