use core::{fmt, result};
pub(super) type Result<T> = result::Result<T, Error>;
#[derive(Debug)]
pub struct Error {
kind: ErrorKind,
error: &'static str,
}
impl core::error::Error for Error {}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub(super) enum ErrorKind {
WriteZero,
Interrupted,
UnexpectedEof,
}
impl Error {
pub(super) fn new(kind: ErrorKind, error: &'static str) -> Error {
Error { kind, error }
}
pub(super) fn kind(&self) -> ErrorKind {
self.kind
}
}
impl fmt::Display for Error {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
self.error.fmt(fmt)
}
}