nectar 0.4.0

Telnet protocol (RFC 854) implementation via a Tokio codec. Includes support for various MUD protocol extensions.
Documentation
use std::{
    error::Error,
    fmt::{Display, Formatter},
    io,
};

#[derive(Debug)]
pub enum TelnetErrorType {
    Codec,
    Io,
}

#[derive(Debug)]
pub struct TelnetError {
    pub kind: TelnetErrorType,
    pub message: String,
}

impl Display for TelnetError {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        write!(f, "{}", self.message)
    }
}

impl From<String> for TelnetError {
    fn from(err: String) -> Self {
        Self { kind: TelnetErrorType::Codec, message: err }
    }
}

impl From<io::Error> for TelnetError {
    fn from(err: io::Error) -> Self {
        Self { kind: TelnetErrorType::Io, message: err.to_string() }
    }
}

impl Error for TelnetError {}