Skip to main content

DocumentMeta

Struct DocumentMeta 

Source
pub struct DocumentMeta {
    pub title: Option<String>,
    pub description: Option<String>,
    pub canonical_url: Option<String>,
    pub site_name: Option<String>,
    pub image_url: Option<String>,
    pub og_type: Option<String>,
    pub twitter_card: Option<String>,
    pub twitter_site: Option<String>,
    pub open_graph: bool,
    pub twitter: bool,
    pub structured_data: bool,
}
Expand description

Optional document metadata supplied by the host for one render call.

The renderer remains a pure function of the opcode stream plus this value: nothing is retained across calls. Title/description set here are fallbacks; META::SET_WINDOW_METADATA values win.

Fields§

§title: Option<String>

Fallback title when the stream does not set WINDOW_METADATA::TITLE.

§description: Option<String>

Fallback description when the stream does not set WINDOW_METADATA::DESCRIPTION.

§canonical_url: Option<String>

Absolute canonical URL for the current view.

§site_name: Option<String>

og:site_name.

§image_url: Option<String>

og:image / twitter:image; when absent the first IMAGE source in the tree is used.

§og_type: Option<String>

og:type (default website).

§twitter_card: Option<String>

twitter:card (default summary, or summary_large_image when an image is available).

§twitter_site: Option<String>

twitter:site (e.g. @pathland).

§open_graph: bool

Emit Open Graph tags.

§twitter: bool

Emit Twitter card tags.

§structured_data: bool

Emit JSON-LD structured data (WebPage + Article).

Implementations§

Source§

impl DocumentMeta

Source

pub fn new() -> Self

No extra metadata — the legacy document head.

Source

pub fn none() -> Self

No extra metadata — the legacy document head.

Source

pub fn seo(canonical_url: impl Into<String>) -> Self

Full SEO head for canonical_url: canonical + Open Graph + Twitter + structured data. Refine with the other builders/fields.

Source

pub fn with_title(self, title: impl Into<String>) -> Self

Set a fallback title.

Source

pub fn with_description(self, description: impl Into<String>) -> Self

Set a fallback description.

Source

pub fn with_canonical_url(self, canonical_url: impl Into<String>) -> Self

Set the canonical URL.

Source

pub fn with_site_name(self, site_name: impl Into<String>) -> Self

Set og:site_name.

Source

pub fn with_image_url(self, image_url: impl Into<String>) -> Self

Set og:image / twitter:image.

Source

pub fn with_og_type(self, og_type: impl Into<String>) -> Self

Set og:type.

Source

pub fn with_twitter_card(self, twitter_card: impl Into<String>) -> Self

Set twitter:card.

Source

pub fn with_twitter_site(self, twitter_site: impl Into<String>) -> Self

Set twitter:site.

Source

pub fn with_open_graph(self, on: bool) -> Self

Enable/disable Open Graph tags.

Source

pub fn with_twitter(self, on: bool) -> Self

Enable/disable Twitter card tags.

Source

pub fn with_structured_data(self, on: bool) -> Self

Enable/disable JSON-LD structured data.

Trait Implementations§

Source§

impl Clone for DocumentMeta

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 DocumentMeta

Source§

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

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

impl Default for DocumentMeta

Source§

fn default() -> Self

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

impl Eq for DocumentMeta

Source§

impl PartialEq for DocumentMeta

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 StructuralPartialEq for DocumentMeta

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.