use crate::storage_engine::Column; #[derive(Debug)] pub enum Error { DecodeError(DecodeErrorKind, bincode::error::DecodeError), EncodeError(bincode::error::EncodeError), AttemptToIndexNonIndexableColumn(Column), IndexIsStoringEofFilePosition(Column), ColumnAlreadyIndexed(Column), IoError(std::io::Error), } #[derive(Debug)] pub enum DecodeErrorKind { StoreHeaderNumberOfColumns, StoreHeaderDeletedCount, StoreHeaderTotalCount, StoreHeaderPrimaryColumn, StoreHeaderIndexedColumns, EntryData, EntryIsDeleted, EntryHeaderWithDataSizes, CorruptedData, } // ===Errors=== impl Error { pub fn to_io_or_panic(self) -> std::io::Error { use Error::*; match self { IoError(err) => err, err => { println!("{:?}", err); panic!(); } } } } impl From for Error { fn from(err: bincode::error::EncodeError) -> Self { Self::EncodeError(err) } } impl From for Error { fn from(err: std::io::Error) -> Self { Self::IoError(err) } }