1#[derive(Debug)]
27pub enum Error {
28 SizeCorrupted,
29 SeekCorrupted,
30 FileFull,
31 ArrayFull,
32 ArrayEmpty,
33 IndexOutOfRange,
34 IndexOutOfBounds,
35 StdNumParseIntError(std::num::ParseIntError),
36 StdIoError(std::io::Error),
37 StdArrayTryFromSliceError(std::array::TryFromSliceError),
38}
39
40impl From<std::num::ParseIntError> for Error {
41 fn from(error: std::num::ParseIntError) -> Self {
42 Self::StdNumParseIntError(error)
43 }
44}
45
46impl From<std::io::Error> for Error {
47 fn from(error: std::io::Error) -> Self {
48 Self::StdIoError(error)
49 }
50}
51
52impl From<std::array::TryFromSliceError> for Error {
53 fn from(error: std::array::TryFromSliceError) -> Self {
54 Self::StdArrayTryFromSliceError(error)
55 }
56}
57
58impl std::fmt::Display for Error {
59 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
60 match self {
61 Self::SizeCorrupted => write!(f, "Size corrupted"),
62 Self::SeekCorrupted => write!(f, "Seek corrupted"),
63 Self::FileFull => write!(f, "File is full"),
64 Self::ArrayFull => write!(f, "Array is full"),
65 Self::ArrayEmpty => write!(f, "Array is empty"),
66 Self::IndexOutOfRange => write!(f, "Index out of range"),
67 Self::IndexOutOfBounds => write!(f, "Index out of bounds"),
68 Self::StdNumParseIntError(e) => std::fmt::Display::fmt(e, f),
69 Self::StdIoError(e) => std::fmt::Display::fmt(e, f),
70 Self::StdArrayTryFromSliceError(e) => std::fmt::Display::fmt(e, f),
71 }
72 }
73}
74
75impl std::error::Error for Error {}