diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/hostfile.rs | 19 | ||||
-rw-r--r-- | src/lib.rs | 3 |
2 files changed, 21 insertions, 1 deletions
diff --git a/src/hostfile.rs b/src/hostfile.rs new file mode 100644 index 0000000..5414125 --- /dev/null +++ b/src/hostfile.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) + } +} @@ -13,11 +13,12 @@ pub use tmux::Tmux; mod config; mod history; +mod hostfile; mod ssh; mod tmux; pub trait SessionSource { - type Error: std::error::Error; + type Error; type Iter: IntoIterator<Item = Session>; |