forward 0.1.0-alpha.1

open a TCP port and foward all trafics through a proxy to another server or port
Documentation
use super::Authentication;

#[derive(PartialEq, Debug)]
pub enum ToAuthenticationError {
    NoUsername,
    NoPassword,
}

pub trait ToAuthentication {
    fn to_authentication(&self) -> Result<Authentication, ToAuthenticationError>;
}

impl ToAuthentication for (Option<String>, Option<String>) {
    fn to_authentication(&self) -> Result<Authentication, ToAuthenticationError> {
        match self {
            (Some(username), Some(password)) => Ok(Authentication::Password {
                username: username.to_string(),
                password: password.to_string(),
            }),
            (Some(_), None) => Err(ToAuthenticationError::NoPassword),
            (None, Some(_)) => Err(ToAuthenticationError::NoUsername),
            (None, None) => Ok(Authentication::None),
        }
    }
}