html_sys/embedded/
map.rs

1/// The HTML `<map>` element
2///
3/// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/map)
4#[doc(alias = "map")]
5#[non_exhaustive]
6#[derive(Debug, Clone, PartialEq, Default)]
7pub struct ImageMap {
8    pub data_map: crate::DataMap,
9    global_attrs: crate::GlobalAttributes,
10    /// Name of image map to reference from the usemap attribute
11    pub name: std::option::Option<std::borrow::Cow<'static, str>>,
12}
13impl crate::RenderElement for ImageMap {
14    fn write_opening_tag<W: std::fmt::Write>(&self, writer: &mut W) -> std::fmt::Result {
15        write!(writer, "<map")?;
16        if let Some(field) = self.name.as_ref() {
17            write!(writer, r#" name="{field}""#)?;
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, "</map>")?;
27        Ok(())
28    }
29}
30impl std::fmt::Display for ImageMap {
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 ImageMap {
39    type Target = crate::GlobalAttributes;
40    fn deref(&self) -> &Self::Target {
41        &self.global_attrs
42    }
43}
44impl std::ops::DerefMut for ImageMap {
45    fn deref_mut(&mut self) -> &mut Self::Target {
46        &mut self.global_attrs
47    }
48}