1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use std::fmt::Formatter;

use crate::parser::parsers::Elms;

#[derive(Debug, Clone, PartialEq, Hash)]
pub struct Scheme(String);

impl Default for Scheme {
  fn default() -> Self {
    Scheme(String::default())
  }
}

impl std::fmt::Display for Scheme {
  fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
    write!(f, "{}", self.0)
  }
}

impl From<String> for Scheme {
  fn from(src: String) -> Self {
    Self(src)
  }
}

impl From<&str> for Scheme {
  fn from(src: &str) -> Self {
    Self(src.to_string())
  }
}

impl From<&[u8]> for Scheme {
  fn from(src: &[u8]) -> Self {
    Self(String::from_utf8(src.to_vec()).unwrap())
  }
}

impl From<Elms<'_>> for Scheme {
  fn from(src: Elms) -> Self {
    Self(src.as_string().unwrap())
  }
}

impl Scheme {
  pub fn new(value: String) -> Self {
    Self(value)
  }
}