// SPDX-License-Identifier: MIT OR Apache-2.0 // Copyright 2020, Alyssa Ross use std::fmt::{self, Display, Formatter}; #[derive(Debug)] pub enum Error { DataError(bincode::Error), IoError(sys_util::Error), } impl Display for Error { fn fmt(&self, f: &mut Formatter) -> fmt::Result { use Error::*; match self { DataError(error) => write!(f, "{}", error), IoError(error) => write!(f, "{}", error), } } } impl From for Error { fn from(error: bincode::Error) -> Self { Self::DataError(error) } } impl From for Error { fn from(error: sys_util::Error) -> Self { Self::IoError(error) } } impl From for Error { fn from(error: std::io::Error) -> Self { Self::IoError(error.into()) } }