1use crate::attribute::{SvgAttribute, extract_attributes, opening_tag_name};
2
3#[derive(Debug, Clone, PartialEq, Eq)]
4pub struct SvgElement {
5 pub name: String,
6 pub attributes: Vec<SvgAttribute>,
7}
8
9impl SvgElement {
10 #[must_use]
11 pub fn new(name: impl Into<String>, attributes: Vec<SvgAttribute>) -> Self {
12 Self {
13 name: name.into(),
14 attributes,
15 }
16 }
17}
18
19#[must_use]
20pub fn parse_element(element: &str) -> Option<SvgElement> {
21 Some(SvgElement::new(
22 opening_tag_name(element)?,
23 extract_attributes(element),
24 ))
25}