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