50 lines
1.1 KiB
Rust
50 lines
1.1 KiB
Rust
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<bincode::error::EncodeError> for Error {
|
|
fn from(err: bincode::error::EncodeError) -> Self {
|
|
Self::EncodeError(err)
|
|
}
|
|
}
|
|
|
|
impl From<std::io::Error> for Error {
|
|
fn from(err: std::io::Error) -> Self {
|
|
Self::IoError(err)
|
|
}
|
|
}
|