diff options
Diffstat (limited to 'src/unix.rs')
-rw-r--r-- | src/unix.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/unix.rs b/src/unix.rs new file mode 100644 index 0000000..5414125 --- /dev/null +++ b/src/unix.rs @@ -0,0 +1,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) + } +} |