1use std::str::Utf8Error;
2
3#[derive(Debug)]
4pub enum Error {
5 InvalidVectorFormat,
6 EOF,
7 Io(std::io::Error),
8 Utf8Error(Utf8Error),
9 DimMismatch(usize, usize),
10}
11
12impl PartialEq for Error {
13 fn eq(&self, other: &Self) -> bool {
14 match (self, other) {
15 (Self::Utf8Error(l0), Self::Utf8Error(r0)) => l0 == r0,
16 _ => core::mem::discriminant(self) == core::mem::discriminant(other),
17 }
18 }
19}
20
21impl From<Utf8Error> for Error {
22 fn from(value: Utf8Error) -> Self {
23 Self::Utf8Error(value)
24 }
25}
26
27impl From<std::io::Error> for Error {
28 fn from(value: std::io::Error) -> Self {
29 Self::Io(value)
30 }
31}
32
33impl std::fmt::Display for Error {
34 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
35 write!(f, "{self:?}")
36 }
37}
38
39impl std::error::Error for Error {}