use crate::io::ErrorKind;
use core::fmt::{self, Display, Formatter};
#[repr(align(4))]
#[derive(Clone, Copy, Debug)]
pub struct SimpleError {
kind: ErrorKind,
message: &'static str,
}
impl SimpleError {
#[inline]
#[must_use]
pub const fn new(kind: ErrorKind, message: &'static str) -> Self {
Self { kind, message }
}
#[inline(always)]
#[must_use]
pub const fn kind(&self) -> ErrorKind {
self.kind
}
#[inline(always)]
#[must_use]
pub const fn message(&self) -> &'static str {
self.message
}
}
impl Display for SimpleError {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "{}: {}", self.kind, self.message)?;
Ok(())
}
}
impl core::error::Error for SimpleError {}