Compare commits
2 commits
f20e410422
...
541d70711c
Author | SHA1 | Date | |
---|---|---|---|
541d70711c | |||
a1619897e3 |
2 changed files with 16 additions and 0 deletions
|
@ -11,6 +11,9 @@ const ICON_SELECTOR: &str =
|
|||
"link[rel~='icon'], link[rel~='apple-touch-icon'], link[rel~='apple-touch-icon-precomposed']";
|
||||
const MANIFEST_SELECTOR: &str = "link[rel~='manifest']";
|
||||
|
||||
/// Represents useful data scraped from HTML.
|
||||
///
|
||||
/// To obtain, use [`HTML::scan_html`].
|
||||
pub struct HTML {
|
||||
pub icons: Vec<Icon>,
|
||||
pub manifest: Option<Url>,
|
||||
|
|
13
src/icon.rs
13
src/icon.rs
|
@ -5,17 +5,30 @@ use url::Url;
|
|||
|
||||
use crate::Error;
|
||||
|
||||
/// The source of a scraped icon.
|
||||
///
|
||||
/// More sources may be added in the future.
|
||||
#[non_exhaustive]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum IconKind {
|
||||
/// Discovered through checking a hardcoded URL path, like `/favicon.ico`
|
||||
HardcodedURL,
|
||||
/// Discovered through parsing the HTML for `<link rel="icon">`s (or similar)
|
||||
LinkedInHTML,
|
||||
/// Discovered through parsing the Web App Manifest linked in the HTML in `<link rel="manifest">`
|
||||
LinkedInManifest,
|
||||
}
|
||||
|
||||
/// A scraped icon.
|
||||
///
|
||||
/// To obtain, use [`crate::scrape`], [`crate::html::HTML::scan_html`], or [`crate::manifest::scan_manifest`].
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Icon {
|
||||
/// Describes how the icon was discovered
|
||||
pub kind: IconKind,
|
||||
/// The source URL of the scraped icon, with redirects resolved
|
||||
pub url: Url,
|
||||
/// The size of the scraped icon, in pixels
|
||||
pub size: ImageSize,
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue