Compare commits
No commits in common. "c0da68f48cd203a49ce73ade5ee28dd9de249df1" and "449f7f59241f745d538748a19ecf89e8a1fa6b98" have entirely different histories.
c0da68f48c
...
449f7f5924
|
@ -20,6 +20,7 @@ impl<B> From<WriteError<B>> for Error<B> {
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum ReadError {
|
pub enum ReadError {
|
||||||
|
Truncated { offset: usize },
|
||||||
InvalidSize { offset: usize, size: usize },
|
InvalidSize { offset: usize, size: usize },
|
||||||
MissingSeparator { offset: usize },
|
MissingSeparator { offset: usize },
|
||||||
Utf8Error(str::Utf8Error),
|
Utf8Error(str::Utf8Error),
|
||||||
|
@ -28,6 +29,8 @@ pub enum ReadError {
|
||||||
impl fmt::Display for ReadError {
|
impl fmt::Display for ReadError {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
|
&ReadError::Truncated { offset }=>
|
||||||
|
write!(f, "truncated record at offset {}", offset),
|
||||||
&ReadError::InvalidSize { offset, size } =>
|
&ReadError::InvalidSize { offset, size } =>
|
||||||
write!(f, "invalid record size {} at offset {}", size, offset),
|
write!(f, "invalid record size {} at offset {}", size, offset),
|
||||||
&ReadError::MissingSeparator { offset } =>
|
&ReadError::MissingSeparator { offset } =>
|
||||||
|
|
|
@ -20,7 +20,7 @@ impl<'a> Iterator for Iter<'a> {
|
||||||
let data = &self.data[self.offset..];
|
let data = &self.data[self.offset..];
|
||||||
|
|
||||||
if data.len() < 4 {
|
if data.len() < 4 {
|
||||||
return None;
|
return Some(Err(ReadError::Truncated { offset: self.offset }))
|
||||||
}
|
}
|
||||||
|
|
||||||
let record_size = BigEndian::read_u32(data) as usize;
|
let record_size = BigEndian::read_u32(data) as usize;
|
||||||
|
|
|
@ -91,6 +91,13 @@ impl<B: StoreBackend> Store<B> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn compact(&mut self) -> Result<(), Error<B::Error>> {
|
fn compact(&mut self) -> Result<(), Error<B::Error>> {
|
||||||
|
// static mut OLD_DATA: B::Data;
|
||||||
|
// let mut old_data = MaybeUninit::<B::Data>::zeroed();
|
||||||
|
// let old_data = unsafe {
|
||||||
|
// let mut old_data = old_data.assume_init();
|
||||||
|
// old_data.copy_from_slice(self.backend.data().as_ref());
|
||||||
|
// old_data
|
||||||
|
// };
|
||||||
let old_data = self.backend.data().clone();
|
let old_data = self.backend.data().clone();
|
||||||
|
|
||||||
self.erase()?;
|
self.erase()?;
|
||||||
|
|
Loading…
Reference in New Issue