uri_parsing_rs/ast/
host_name.rs1use std::fmt::Formatter;
2
3#[derive(Debug, Clone, PartialEq, Hash)]
4pub struct HostName(String);
5
6impl Default for HostName {
7 fn default() -> Self {
8 HostName(String::default())
9 }
10}
11
12impl std::fmt::Display for HostName {
13 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
14 write!(f, "{}", self.0)
15 }
16}
17
18impl From<&str> for HostName {
19 fn from(src: &str) -> Self {
20 Self(src.to_string())
21 }
22}
23
24impl From<String> for HostName {
25 fn from(src: String) -> Self {
26 Self(src)
27 }
28}
29
30impl HostName {
31 pub fn new(value: String) -> Self {
32 Self(value)
33 }
34}