Skip to main content

Metadata

Struct Metadata 

Source
#[non_exhaustive]
pub struct Metadata {
Show 13 fields pub title: Option<String>, pub description: Option<String>, pub canonical: Option<String>, pub lang: Option<String>, pub site_name: Option<String>, pub image: Option<String>, pub author: Option<String>, pub published: Option<String>, pub keywords: Vec<String>, pub og: Vec<(String, String)>, pub twitter: Vec<(String, String)>, pub json_ld: Vec<String>, pub feeds: Vec<String>,
}
Expand description

Metadata about a page, from its <title>, <meta> and <link> tags, JSON-LD blocks and a few in-page conventions. Built by Dom::metadata.

Every field is owned, so the struct outlives the Dom. Scalar fields take the first non-empty value from a list of sources, in the order given on each field; text fields have their whitespace collapsed, URL fields are trimmed but not resolved (use resolve_url with the page URL or Dom::base_url).

With the serde feature, Metadata implements serde::Serialize (a map with one key per field).

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§title: Option<String>

<title> (not one inside an <svg>), else og:title, else twitter:title.

§description: Option<String>

<meta name=description>, else og:description, else twitter:description.

§canonical: Option<String>

<link rel=canonical href>, else og:url.

§lang: Option<String>

The lang of the <html> element, else <meta http-equiv=content-language>.

§site_name: Option<String>

og:site_name, else <meta name=application-name>.

§image: Option<String>

og:image (or og:image:url, og:image:secure_url), else twitter:image (or twitter:image:src), else <link rel=image_src>.

§author: Option<String>

<meta name=author>, else article:author unless it is a URL, else the text of the first <a rel=author>, else the article:author URL.

§published: Option<String>

The publication date as written (usually ISO 8601): article:published_time, else <meta itemprop=datePublished>, else a date-style <meta name> (date, pubdate, publish-date, dc.date, dc.date.issued, dcterms.date, dcterms.created, …), else the datetime of the first <time> that is inside an <article> or carries pubdate / itemprop=datePublished.

§keywords: Vec<String>

<meta name=keywords> (else news_keywords) split on commas, else the article:tag values.

§og: Vec<(String, String)>

Every OpenGraph <meta property=… content=…> pair — properties in the og:, article:, book:, profile:, music: and video: namespaces — in document order, with the full, lower-cased property name as the key ("og:title", "article:published_time"). Repeated properties (several og:images) are all kept.

§twitter: Vec<(String, String)>

Every Twitter-card <meta name=twitter:… content=…> pair (also when written with property=), in document order, keys lower-cased ("twitter:card").

§json_ld: Vec<String>

The raw, trimmed contents of each non-empty <script type="application/ld+json">, in document order. Not parsed: hand them to a JSON parser.

§feeds: Vec<String>

The href of each <link rel=alternate> whose type is RSS (application/rss+xml), Atom (application/atom+xml) or JSON Feed (application/feed+json), in document order.

Trait Implementations§

Source§

impl Clone for Metadata

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Metadata

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Metadata

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for Metadata

Source§

impl PartialEq for Metadata

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Metadata

Available on crate feature serde only.
Source§

fn serialize<S: Serializer>(&self, s: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Metadata

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.