html_sys/embedded/
picture.rs

1/// The HTML `<picture>` element
2///
3/// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/picture)
4#[doc(alias = "picture")]
5#[non_exhaustive]
6#[derive(Debug, Clone, PartialEq, Default)]
7pub struct Picture {
8    pub data_map: crate::DataMap,
9    global_attrs: crate::GlobalAttributes,
10    /// Indicates whether the element is exposed to an accessibility API. See related aria-disabled.
11    pub aria_hidden: bool,
12}
13impl crate::RenderElement for Picture {
14    fn write_opening_tag<W: std::fmt::Write>(&self, writer: &mut W) -> std::fmt::Result {
15        write!(writer, "<picture")?;
16        if self.aria_hidden {
17            write!(writer, r#" aria-hidden"#)?;
18        }
19        write!(writer, "{}", self.global_attrs)?;
20        write!(writer, "{}", self.data_map)?;
21        write!(writer, ">")?;
22        Ok(())
23    }
24    #[allow(unused_variables)]
25    fn write_closing_tag<W: std::fmt::Write>(&self, writer: &mut W) -> std::fmt::Result {
26        write!(writer, "</picture>")?;
27        Ok(())
28    }
29}
30impl std::fmt::Display for Picture {
31    fn fmt(&self, writer: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
32        use crate::RenderElement;
33        self.write_opening_tag(writer)?;
34        self.write_closing_tag(writer)?;
35        Ok(())
36    }
37}
38impl std::ops::Deref for Picture {
39    type Target = crate::GlobalAttributes;
40    fn deref(&self) -> &Self::Target {
41        &self.global_attrs
42    }
43}
44impl std::ops::DerefMut for Picture {
45    fn deref_mut(&mut self) -> &mut Self::Target {
46        &mut self.global_attrs
47    }
48}