#![doc = "Shared protocol error types for MSRT."]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum ErrorKind {
Malformed,
BufferTooSmall,
Frame,
Reliability,
Channel,
Engine,
Unsupported,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct Error {
kind: ErrorKind,
}
impl Error {
#[must_use]
pub const fn new(kind: ErrorKind) -> Self {
Self { kind }
}
#[must_use]
pub const fn kind(self) -> ErrorKind {
self.kind
}
#[must_use]
pub const fn malformed() -> Self {
Self::new(ErrorKind::Malformed)
}
#[must_use]
pub const fn buffer_too_small() -> Self {
Self::new(ErrorKind::BufferTooSmall)
}
#[must_use]
pub const fn unsupported() -> Self {
Self::new(ErrorKind::Unsupported)
}
}
pub type Result<T> = core::result::Result<T, Error>;