html_sys/metadata/
meta.rs1#[doc(alias = "meta")]
5#[non_exhaustive]
6#[derive(Debug, Clone, PartialEq, Default)]
7pub struct Meta {
8 pub data_map: crate::DataMap,
9 global_attrs: crate::GlobalAttributes,
10 pub name: std::option::Option<std::borrow::Cow<'static, str>>,
12 pub http_equiv: std::option::Option<std::borrow::Cow<'static, str>>,
14 pub content: std::option::Option<std::borrow::Cow<'static, str>>,
16 pub charset: std::option::Option<std::borrow::Cow<'static, str>>,
18 pub media: std::option::Option<std::borrow::Cow<'static, str>>,
20}
21impl crate::RenderElement for Meta {
22 fn write_opening_tag<W: std::fmt::Write>(&self, writer: &mut W) -> std::fmt::Result {
23 write!(writer, "<meta")?;
24 if let Some(field) = self.name.as_ref() {
25 write!(writer, r#" name="{field}""#)?;
26 }
27 if let Some(field) = self.http_equiv.as_ref() {
28 write!(writer, r#" http-equiv="{field}""#)?;
29 }
30 if let Some(field) = self.content.as_ref() {
31 write!(writer, r#" content="{field}""#)?;
32 }
33 if let Some(field) = self.charset.as_ref() {
34 write!(writer, r#" charset="{field}""#)?;
35 }
36 if let Some(field) = self.media.as_ref() {
37 write!(writer, r#" media="{field}""#)?;
38 }
39 write!(writer, "{}", self.global_attrs)?;
40 write!(writer, "{}", self.data_map)?;
41 write!(writer, ">")?;
42 Ok(())
43 }
44 #[allow(unused_variables)]
45 fn write_closing_tag<W: std::fmt::Write>(&self, writer: &mut W) -> std::fmt::Result {
46 Ok(())
47 }
48}
49impl std::fmt::Display for Meta {
50 fn fmt(&self, writer: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
51 use crate::RenderElement;
52 self.write_opening_tag(writer)?;
53 self.write_closing_tag(writer)?;
54 Ok(())
55 }
56}
57impl std::ops::Deref for Meta {
58 type Target = crate::GlobalAttributes;
59 fn deref(&self) -> &Self::Target {
60 &self.global_attrs
61 }
62}
63impl std::ops::DerefMut for Meta {
64 fn deref_mut(&mut self) -> &mut Self::Target {
65 &mut self.global_attrs
66 }
67}