html_types/
url.rs

1use crate::attributes::Value;
2
3//TODO actually implement
4pub struct AbsoluteUrl(String);
5
6//TODO actually implement
7pub struct Relative(String);
8
9pub enum Url {
10    Absolute(AbsoluteUrl),
11    Relative(Relative),
12}
13
14impl Url {
15    pub fn absolute_unchecked(text: String) -> Self {
16        let abs = AbsoluteUrl(text);
17        Url::Absolute(abs)
18    }
19}
20
21impl<'a> From<Url> for Value<'a> {
22    fn from(value: Url) -> Self {
23        match value {
24            Url::Absolute(s) => Value::owned(s.0).unwrap(),
25            Url::Relative(s) => Value::owned(s.0).unwrap(),
26        }
27    }
28}