blob: 2115465e24029984cd8de59e71f772a878fe7b76 (
plain)
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
|
use std::ffi::OsString;
use crate::{Session, State};
pub struct HostName(OsString);
impl HostName {
pub fn get() -> Result<Self, std::io::Error> {
hostname::get().map(Self)
}
}
impl From<HostName> for Session {
fn from(value: HostName) -> Self {
Session {
name: value.0.to_string_lossy().into(),
state: State::LocalHost,
}
}
}
impl IntoIterator for HostName {
type Item = Session;
type IntoIter = std::option::IntoIter<Session>;
fn into_iter(self) -> Self::IntoIter {
Some(self.into()).into_iter()
}
}
|