Skip to main content

Metadata

Struct Metadata 

Source
pub struct Metadata {
Show 22 fields pub title: Option<String>, pub title_template: Option<String>, pub title_absolute: bool, pub description: Option<String>, pub keywords: Option<Vec<String>>, pub authors: Option<Vec<String>>, pub canonical: Option<String>, pub robots: Option<String>, pub viewport: Option<String>, pub theme_color: Option<String>, pub color_scheme: Option<String>, pub manifest: Option<String>, pub icons: Option<Vec<Icon>>, pub open_graph: Option<OpenGraph>, pub twitter: Option<Twitter>, pub alternates: Option<Vec<(String, String)>>, pub other: Vec<(String, String)>, pub stylesheets: Vec<String>, pub preloads: Vec<Preload>, pub links: Vec<LinkTag>, pub html_attributes: Vec<(String, String)>, pub theme_colors: Vec<(String, String)>,
}

Fields§

§title: Option<String>§title_template: Option<String>

Applied to descendant titles; %s is replaced by the child title.

§title_absolute: bool

When true, this title ignores ancestor templates.

§description: Option<String>§keywords: Option<Vec<String>>§authors: Option<Vec<String>>§canonical: Option<String>§robots: Option<String>§viewport: Option<String>§theme_color: Option<String>§color_scheme: Option<String>§manifest: Option<String>§icons: Option<Vec<Icon>>§open_graph: Option<OpenGraph>§twitter: Option<Twitter>§alternates: Option<Vec<(String, String)>>

hreflang alternates: (language, url).

§other: Vec<(String, String)>

Extra <meta name=.. content=..> entries.

§stylesheets: Vec<String>

External stylesheets (<link rel="stylesheet">).

§preloads: Vec<Preload>

Preloaded resources (fonts, images).

§links: Vec<LinkTag>

Extra <link> tags: feeds, preconnect, me, …

§html_attributes: Vec<(String, String)>

Attributes of the <html> element: (name, value).

§theme_colors: Vec<(String, String)>

theme-color per media query: (media, color).

Implementations§

Source§

impl Metadata

Source

pub fn new() -> Metadata

Source

pub fn title(self, v: impl Into<String>) -> Metadata

Source

pub fn title_template(self, v: impl Into<String>) -> Metadata

Source

pub fn description(self, v: impl Into<String>) -> Metadata

Source

pub fn canonical(self, v: impl Into<String>) -> Metadata

Source

pub fn robots(self, v: impl Into<String>) -> Metadata

Source

pub fn viewport(self, v: impl Into<String>) -> Metadata

Source

pub fn theme_color(self, v: impl Into<String>) -> Metadata

Source

pub fn color_scheme(self, v: impl Into<String>) -> Metadata

Source

pub fn manifest(self, v: impl Into<String>) -> Metadata

Source

pub fn absolute_title(self, v: impl Into<String>) -> Metadata

A title that ignores ancestor templates.

Source

pub fn keywords<I, S>(self, v: I) -> Metadata
where I: IntoIterator<Item = S>, S: Into<String>,

Source

pub fn authors<I, S>(self, v: I) -> Metadata
where I: IntoIterator<Item = S>, S: Into<String>,

Source

pub fn icon(self, href: impl Into<String>) -> Metadata

Source

pub fn icon_sized( self, href: impl Into<String>, sizes: impl Into<String>, mime: impl Into<String>, ) -> Metadata

An icon with its size and type, for browsers that pick one of several: icon_sized("/favicon-32x32.png", "32x32", "image/png").

Source

pub fn theme_color_for( self, media: impl Into<String>, color: impl Into<String>, ) -> Metadata

A theme-color for one media query, typically once for each color scheme: theme_color_for("(prefers-color-scheme: dark)", "#0d1b2a"). A plain theme_color is still written first, for browsers that ignore media. A child that sets any replaces the parent’s list.

Source

pub fn apple_touch_icon(self, href: impl Into<String>) -> Metadata

Source

pub fn open_graph(self, og: OpenGraph) -> Metadata

Source

pub fn twitter(self, tw: Twitter) -> Metadata

Source

pub fn alternate( self, lang: impl Into<String>, href: impl Into<String>, ) -> Metadata

Source

pub fn meta( self, name: impl Into<String>, content: impl Into<String>, ) -> Metadata

Source

pub fn stylesheet(self, href: impl Into<String>) -> Metadata

Source

pub fn preload_font(self, href: impl Into<String>) -> Metadata

Preload a font file (adds crossorigin, required for fonts).

Source

pub fn preload_image(self, href: impl Into<String>) -> Metadata

A <link> tag: link("preconnect", "https://cdn.example.com").

Source

pub fn html_attribute( self, name: impl Into<String>, value: impl Into<String>, ) -> Metadata

An attribute of the <html> element, e.g. html_attribute("data-theme", "ocean") or html_attribute("class", "dark"), so a theme applies before any script runs. lang overrides [app] lang for the page.

The element is written with the document: client-side navigations keep the attributes the page already has (and what scripts changed since). Names that are not valid attribute names and event handlers (on*) are never rendered; values are escaped, and class gets the same short names as every other class in release builds.

Source

pub fn feed( self, title: impl Into<String>, href: impl Into<String>, mime: impl Into<String>, ) -> Metadata

A feed readers can subscribe to. Browsers and feed readers look for rel="alternate" with a feed media type: feed("RSS", "/feed.xml", "application/rss+xml").

Source

pub fn merge(self, child: Metadata) -> Metadata

Merge child into self (child wins).

Source

pub fn render_head(&self) -> String

Render <head> contents.

Trait Implementations§

Source§

impl Clone for Metadata

Source§

fn clone(&self) -> Metadata

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<(), Error>

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

impl Default for Metadata

Source§

fn default() -> Metadata

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

impl Eq for Metadata

Source§

impl IntoResult<Metadata> for Metadata

Source§

impl PartialEq for Metadata

Source§

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

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

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

Inequality operator !=. 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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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> Same for T

Source§

type Output = T

Should always be Self
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.