1use crate::{
2 ns::*,
3 XmlError,
4 XmlReader,
5 XmlWriter,
6};
7
8#[derive(Clone)]
9#[derive(Debug)]
10#[derive(Eq, PartialEq)]
11#[derive(Ord, PartialOrd)]
12pub struct Href(pub String);
13
14impl Href {
15 pub fn as_str(&self) -> &str {
16 self.0.as_str()
17 }
18
19 pub fn from_xml(reader: &mut XmlReader) -> Result<Self, XmlError> {
20 reader.open(DAV, "href")?;
21 let href = reader.text()?;
22 reader.close()?;
23
24 Ok(Self(href))
25 }
26
27 pub fn to_xml(&self, writer: &mut XmlWriter) -> Result<(), XmlError> {
28 writer.open_local("href")?;
29 writer.text(&self.0)?;
30 writer.close()
31 }
32}
33
34impl PartialEq<str> for Href {
35 fn eq(&self, with: &str) -> bool {
36 self.0.eq(with)
37 }
38}
39
40impl PartialEq<String> for Href {
41 fn eq(&self, with: &String) -> bool {
42 self.0.eq(with)
43 }
44}
45