pub struct LinkPreview {
pub title: Option<String>,
pub description: Option<String>,
pub domain: Option<String>,
pub image_url: Option<Url>,
}Expand description
Represents a link preview, which contains metadata about a web page
Fields§
§title: Option<String>§description: Option<String>§domain: Option<String>§image_url: Option<Url>Implementations§
Source§impl LinkPreview
impl LinkPreview
Sourcepub fn image_url_str(&self) -> Option<String>
pub fn image_url_str(&self) -> Option<String>
Retrieves the String representation of image_url Url instance
Sourcepub fn find_first_domain(html: &Html) -> Option<String>
pub fn find_first_domain(html: &Html) -> Option<String>
Attempts to find the description of the page in the following order:
- Document’s
<link rel="canonical" /> element'shref` attribute - OpenGraphTag’s image meta tag (
og:image)
Sourcepub fn find_first_image_url(html: &Html) -> Option<Url>
pub fn find_first_image_url(html: &Html) -> Option<Url>
Attempts to find the description of the page in the following order:
- OpenGraphTag’s image meta tag (
og:image) - Document’s
<link rel="image_url" /> element'shref` attribute - Twitter Card’s image meta tag (
twitter:image) - Schema.org image meta tag (
image)
Sourcepub fn find_first_description(html: &Html) -> Option<String>
pub fn find_first_description(html: &Html) -> Option<String>
Attempts to find the description of the page in the following order:
- OpenGraphTag’s description meta tag (
og:description) - Twitter Card’s description meta tag (
twitter:description) - Schema.org description meta tag (
description) - Description meta tag (
description) - The first
pelement from the document
Sourcepub fn find_first_title(html: &Html) -> Option<String>
pub fn find_first_title(html: &Html) -> Option<String>
Attempts to find the title of the page in the following order:
- OpenGraphTag’s title meta tag (
og:title) - Twitter Card’s title meta tag (
twitter:title) - Schema.org title meta tag (
title) - The HTML’s document title
- The first
<h1>tag in the document - The first
<h2>tag in the document
Trait Implementations§
Source§impl Clone for LinkPreview
impl Clone for LinkPreview
Source§fn clone(&self) -> LinkPreview
fn clone(&self) -> LinkPreview
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LinkPreview
impl Debug for LinkPreview
Source§impl From<&Html> for LinkPreview
impl From<&Html> for LinkPreview
Source§impl From<Html> for LinkPreview
impl From<Html> for LinkPreview
Auto Trait Implementations§
impl Freeze for LinkPreview
impl RefUnwindSafe for LinkPreview
impl Send for LinkPreview
impl Sync for LinkPreview
impl Unpin for LinkPreview
impl UnwindSafe for LinkPreview
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more