Add more docs

This commit is contained in:
CenTdemeern1 2025-02-01 00:53:22 +01:00
parent a1619897e3
commit 541d70711c
2 changed files with 15 additions and 0 deletions

View file

@ -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>,

View file

@ -5,18 +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,
}