Print first n entries
This commit is contained in:
parent
eb034592fa
commit
cad4ba8215
5 changed files with 481 additions and 316 deletions
44
storage_engine/src/error.rs
Normal file
44
storage_engine/src/error.rs
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
DecodeError(DecodeErrorKind, bincode::error::DecodeError),
|
||||
EncodeError(bincode::error::EncodeError),
|
||||
IoError(std::io::Error),
|
||||
InvalidStoreHeader,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum DecodeErrorKind {
|
||||
StoreHeaderNumberOfColumns,
|
||||
StoreHeaderDeletedCount,
|
||||
EntryData,
|
||||
EntryIsDeleted,
|
||||
EntryDataSize
|
||||
}
|
||||
|
||||
// ===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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue