summaryrefslogtreecommitdiffstats
path: root/src/hostfile.rs
blob: 5414125ee4b36fac8c826ac0084005e8aa3f12c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use crate::{Session, SessionSource};

pub struct HostFile;

impl SessionSource for HostFile {
    type Error = &'static str;

    type Iter = Vec<Session>;

    fn sessions(&self) -> Result<Self::Iter, Self::Error> {
        let sessions = hostfile::parse_hostfile()?
            .into_iter()
            .flat_map(|h| h.names.into_iter())
            .map(Into::into)
            .collect();

        Ok(sessions)
    }
}