favicon_scrapper/
metadata.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use crate::Format;

#[derive(Debug, Default, PartialEq)]
/// Favicon metadata.
pub struct Metadata {
    pub(crate) format: Format,
    pub(crate) size: Option<(u32, u32)>,
}

impl Metadata {
    pub(crate) fn new(format: Format) -> Self {
        Self { format, size: None }
    }

    #[allow(dead_code)]
    pub(crate) fn with_size(format: Format, size: (u32, u32)) -> Self {
        Self {
            format,
            size: Some(size),
        }
    }

    /// The favicon's image format.
    pub fn format(&self) -> &Format {
        &self.format
    }

    /// The favicon's size if was specified in the HTML tags.
    pub fn size(&self) -> Option<(u32, u32)> {
        self.size
    }
}