Skip to main content

MetaTagGroups

Struct MetaTagGroups 

Source
pub struct MetaTagGroups {
    pub apple: String,
    pub primary: String,
    pub og: String,
    pub ms: String,
    pub twitter: String,
}
Expand description

Holds collections of meta tags for different platforms and categories.

§Example

use metadata_gen::metatags::generate_metatags;
use std::collections::HashMap;

let mut metadata = HashMap::new();
metadata.insert("description".to_string(), "A sample page".to_string());
metadata.insert("og:title".to_string(), "Sample".to_string());

let tags = generate_metatags(&metadata);
assert!(tags.primary.contains("description"));
assert!(tags.og.contains("og:title"));

Fields§

§apple: String

The apple meta tags.

§primary: String

The primary meta tags.

§og: String

The og meta tags.

§ms: String

The ms meta tags.

§twitter: String

The twitter meta tags.

Implementations§

Source§

impl MetaTagGroups

Source

pub fn add_custom_tag(&mut self, name: &str, content: &str)

Adds a custom meta tag to the appropriate group.

§Arguments
  • name - The name of the meta tag.
  • content - The content of the meta tag.
Source

pub fn format_meta_tag(&self, name: &str, content: &str) -> String

Formats a single meta tag.

§Arguments
  • name - The name of the meta tag.
  • content - The content of the meta tag.
§Returns

A formatted meta tag string.

Source

pub fn generate_apple_meta_tags(&mut self, metadata: &HashMap<String, String>)

Generates meta tags for Apple devices.

§Arguments
  • metadata - A reference to a HashMap containing the metadata.
Source

pub fn generate_primary_meta_tags(&mut self, metadata: &HashMap<String, String>)

Generates primary meta tags like author, description, and keywords.

§Arguments
  • metadata - A reference to a HashMap containing the metadata.
Source

pub fn generate_og_meta_tags(&mut self, metadata: &HashMap<String, String>)

Generates Open Graph (og) meta tags for social media.

§Arguments
  • metadata - A reference to a HashMap containing the metadata.
Source

pub fn generate_ms_meta_tags(&mut self, metadata: &HashMap<String, String>)

Generates Microsoft-specific meta tags.

§Arguments
  • metadata - A reference to a HashMap containing the metadata.
Source

pub fn generate_twitter_meta_tags(&mut self, metadata: &HashMap<String, String>)

Generates Twitter meta tags for embedding rich media in tweets.

§Arguments
  • metadata - A reference to a HashMap containing the metadata.
Source

pub fn generate_tags( &self, metadata: &HashMap<String, String>, tags: &[&str], ) -> String

Generates meta tags based on the provided list of tag names.

§Arguments
  • metadata - A reference to a HashMap containing the metadata.
  • tags - A reference to an array of tag names.
§Returns

A string containing the generated meta tags.

Trait Implementations§

Source§

impl Clone for MetaTagGroups

Source§

fn clone(&self) -> MetaTagGroups

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 MetaTagGroups

Source§

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

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

impl Default for MetaTagGroups

Source§

fn default() -> MetaTagGroups

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

impl Display for MetaTagGroups

Implement Display for MetaTagGroups.

Source§

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

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

impl Eq for MetaTagGroups

Source§

impl Hash for MetaTagGroups

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for MetaTagGroups

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for MetaTagGroups

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
§

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

§

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

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

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

§

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<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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.