hyper-noise 0.0.2

A Noise protocol encryption layer on top of hyper HTTP servers and clients.
Documentation
#[derive(Debug)]
pub enum ServerError {
    Hyper(hyper::Error),
    Noise(tokio_noise::NoiseError),
    HandlerTimeout,
}

impl From<hyper::Error> for ServerError {
    fn from(e: hyper::Error) -> Self {
        ServerError::Hyper(e)
    }
}
impl From<tokio_noise::NoiseError> for ServerError {
    fn from(e: tokio_noise::NoiseError) -> Self {
        ServerError::Noise(e)
    }
}

impl std::fmt::Display for ServerError {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        use ServerError::*;
        write!(
            f,
            "noise HTTP server error: {}",
            match self {
                Hyper(e) => format!("hyper error: {e}"),
                Noise(e) => format!("noise error: {e}"),
                HandlerTimeout => "timed out handling noise HTTP request".to_string(),
            }
        )
    }
}

impl std::error::Error for ServerError {}

#[derive(Debug)]
pub enum ClientError {
    Hyper(hyper::Error),
    Noise(tokio_noise::NoiseError),
    RequestTimeout,
}

impl From<hyper::Error> for ClientError {
    fn from(e: hyper::Error) -> Self {
        Self::Hyper(e)
    }
}
impl From<tokio_noise::NoiseError> for ClientError {
    fn from(e: tokio_noise::NoiseError) -> Self {
        Self::Noise(e)
    }
}

impl std::fmt::Display for ClientError {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        use ClientError::*;
        write!(
            f,
            "noise HTTP client error: {}",
            match self {
                Hyper(e) => format!("hyper error: {e}"),
                Noise(e) => format!("noise error: {e}"),
                RequestTimeout => "timed out waiting for noise HTTP response".to_string(),
            }
        )
    }
}

impl std::error::Error for ClientError {}