use std::io;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum ProtocolError {
#[error("I/O error: {0}")]
Io(#[from] io::Error),
#[error("malformed message: {0}")]
Malformed(String),
#[error("invalid LiNo: {0}")]
InvalidLino(String),
#[error("limit exceeded: {0}")]
LimitExceeded(String),
#[error("cannot encode: {0}")]
Unencodable(String),
#[error("server error: {0}")]
Remote(String),
}
impl ProtocolError {
pub(crate) fn malformed(message: impl Into<String>) -> Self {
Self::Malformed(message.into())
}
}
pub type ProtocolResult<T> = Result<T, ProtocolError>;