pub struct DocumentMetadata {
pub title: Option<String>,
pub description: Option<String>,
pub keywords: Vec<String>,
pub author: Option<String>,
pub canonical_url: Option<String>,
pub base_href: Option<String>,
pub language: Option<String>,
pub text_direction: Option<TextDirection>,
pub open_graph: BTreeMap<String, String>,
pub twitter_card: BTreeMap<String, String>,
pub meta_tags: BTreeMap<String, String>,
}Expand description
Document-level metadata extracted from <head> and top-level elements.
Contains all metadata typically used by search engines, social media platforms, and browsers for document indexing and presentation.
§Examples
let doc = DocumentMetadata {
title: Some("My Article".to_string()),
description: Some("A great article about Rust".to_string()),
keywords: vec!["rust".to_string(), "programming".to_string()],
..Default::default()
};
assert_eq!(doc.title, Some("My Article".to_string()));Fields§
§title: Option<String>Document title from <title> tag
description: Option<String>Document description from <meta name="description"> tag
keywords: Vec<String>Document keywords from <meta name="keywords"> tag, split on commas
Document author from <meta name="author"> tag
canonical_url: Option<String>Canonical URL from <link rel="canonical"> tag
base_href: Option<String>Base URL from <base href=""> tag for resolving relative URLs
language: Option<String>Document language from lang attribute
text_direction: Option<TextDirection>Document text direction from dir attribute
open_graph: BTreeMap<String, String>Open Graph metadata (og:* properties) for social media Keys like “title”, “description”, “image”, “url”, etc.
twitter_card: BTreeMap<String, String>Twitter Card metadata (twitter:* properties) Keys like “card”, “site”, “creator”, “title”, “description”, “image”, etc.
Additional meta tags not covered by specific fields Keys are meta name/property attributes, values are content
Trait Implementations§
Source§impl Clone for DocumentMetadata
impl Clone for DocumentMetadata
Source§fn clone(&self) -> DocumentMetadata
fn clone(&self) -> DocumentMetadata
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DocumentMetadata
impl Debug for DocumentMetadata
Source§impl Default for DocumentMetadata
impl Default for DocumentMetadata
Source§fn default() -> DocumentMetadata
fn default() -> DocumentMetadata
Source§impl<'de> Deserialize<'de> for DocumentMetadata
impl<'de> Deserialize<'de> for DocumentMetadata
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for DocumentMetadata
impl RefUnwindSafe for DocumentMetadata
impl Send for DocumentMetadata
impl Sync for DocumentMetadata
impl Unpin for DocumentMetadata
impl UnwindSafe for DocumentMetadata
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)