1use std::{
2 fmt::{self, Debug},
3 io,
4};
5
6pub type Result<T, E = Error> = std::result::Result<T, E>;
7
8#[derive(Debug)]
9pub enum Error {
10 IO(io::Error),
11 ZeroCopyError,
12}
13
14impl From<io::Error> for Error {
15 fn from(value: io::Error) -> Self {
16 Self::IO(value)
17 }
18}
19
20impl<A, B> From<zerocopy::error::SizeError<A, B>> for Error {
21 fn from(_: zerocopy::error::SizeError<A, B>) -> Self {
22 Self::ZeroCopyError
23 }
24}
25
26impl fmt::Display for Error {
27 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
28 match self {
29 Error::IO(error) => Debug::fmt(&error, f),
30 Error::ZeroCopyError => write!(f, "Zero copy convert error"),
31 }
32 }
33}
34
35impl std::error::Error for Error {}