summaryrefslogtreecommitdiffstats
path: root/src/localhost.rs
blob: 45b14de61a0f7722afb53be6b05bfd33cfa8a8ba (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
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 IntoIterator for HostName {
    type Item = Session;

    type IntoIter = std::option::IntoIter<Session>;

    fn into_iter(self) -> Self::IntoIter {
        Some(Session {
            name: self.0.to_string_lossy().into(),
            state: State::LocalHost,
        })
        .into_iter()
    }
}