From 04814c4996140871674d7ce5552f55d9ba07615a Mon Sep 17 00:00:00 2001 From: Toby Vincent Date: Sat, 24 Feb 2024 18:09:58 -0600 Subject: feat!: remove tmux functionalilty and more async --- src/lib.rs | 66 ++------------------------------------------------------------ 1 file changed, 2 insertions(+), 64 deletions(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 9417b71..bf1ff82 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,66 +1,4 @@ -use std::{ - convert::Infallible, - fmt::Display, - net::{IpAddr, Ipv4Addr, Ipv6Addr}, - str::FromStr, -}; +pub use error::{Error, Result}; +pub mod error; pub mod netlink; -pub mod tmux; - -#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub enum Host { - IpAddr(IpAddr), - Hostname(String), -} - -impl Host { - pub fn resolve(&self) -> std::io::Result { - match self { - Self::IpAddr(ip) => dns_lookup::lookup_addr(ip).map(Self::Hostname), - Self::Hostname(h) => dns_lookup::lookup_host(h)? - .first() - .cloned() - .map(Self::IpAddr) - .ok_or(std::io::Error::new( - std::io::ErrorKind::NotFound, - "resolution not enabled", - )), - } - } -} - -impl FromStr for Host { - type Err = Infallible; - - fn from_str(s: &str) -> Result { - Ok(IpAddr::from_str(s).map_or_else(|_| Self::Hostname(s.to_string()), Host::from)) - } -} - -impl From for Host { - fn from(value: IpAddr) -> Self { - Self::IpAddr(value) - } -} - -impl From for Host { - fn from(value: Ipv4Addr) -> Self { - IpAddr::from(value).into() - } -} - -impl From for Host { - fn from(value: Ipv6Addr) -> Self { - IpAddr::from(value).into() - } -} - -impl Display for Host { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Host::IpAddr(i) => write!(f, "{}", i), - Host::Hostname(s) => write!(f, "{}", s), - } - } -} -- cgit v1.2.3-70-g09d2