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