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