1use core::fmt;
2
3pub type Result<T> = core::result::Result<T, Error>;
5
6#[derive(Clone, Copy, Debug, Eq, PartialEq)]
8pub enum Error {
9 InvalidVariant,
10 InvalidValue(usize),
11}
12
13impl Error {
14 pub const fn new() -> Self {
16 Self::InvalidVariant
17 }
18}
19
20impl Default for Error {
21 fn default() -> Self {
22 Self::new()
23 }
24}
25
26impl fmt::Display for Error {
27 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
28 match self {
29 Self::InvalidVariant => write!(f, "invalid variant"),
30 Self::InvalidValue(err) => write!(f, "invalid value: {err}"),
31 }
32 }
33}
34
35impl core::error::Error for Error {}