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
use std::fmt::Formatter;
#[derive(Debug, Clone, PartialEq, Hash)]
pub struct HostName(String);
impl Default for HostName {
fn default() -> Self {
HostName(String::default())
}
}
impl std::fmt::Display for HostName {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
impl From<&str> for HostName {
fn from(src: &str) -> Self {
Self(src.to_string())
}
}
impl From<String> for HostName {
fn from(src: String) -> Self {
Self(src)
}
}
impl HostName {
pub fn new(value: String) -> Self {
Self(value)
}
}