1use xml::escape::escape_str_attribute;
2
3use std::fmt;
4
5#[derive(Clone, Debug, PartialEq, Eq)]
6pub struct Attribute {
7 pub name: String,
8 pub value: String,
9}
10
11impl fmt::Display for Attribute {
12 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
13 write!(fmt, "{}=\"{}\"", self.name, escape_str_attribute(&self.value))
14 }
15}
16
17impl Attribute {
18 pub fn new<N: Into<String>, V: Into<String>>(name: N, value: V) -> Attribute {
19 Attribute {
20 name: name.into(),
21 value: value.into(),
22 }
23 }
24}