feat(code): finish part 3

Signed-off-by: Alex Chi <iskyzh@gmail.com>
This commit is contained in:
Alex Chi
2022-12-24 14:48:57 -05:00
parent 4eb2177a3e
commit 3ed6204400
19 changed files with 517 additions and 101 deletions

View File

@@ -1 +1,54 @@
#![allow(unused_variables)] // TODO(you): remove this lint after implementing this mod
#![allow(dead_code)] // TODO(you): remove this lint after implementing this mod
use crate::iterators::impls::StorageIterator;
use anyhow::Result;
pub struct LsmIterator {}
impl StorageIterator for LsmIterator {
fn is_valid(&self) -> bool {
unimplemented!()
}
fn key(&self) -> &[u8] {
unimplemented!()
}
fn value(&self) -> &[u8] {
unimplemented!()
}
fn next(&mut self) -> Result<()> {
unimplemented!()
}
}
/// A wrapper around existing iterator, will prevent users from calling `next` when the iterator is invalid.
pub struct FusedIterator<I: StorageIterator> {
iter: I,
}
impl<I: StorageIterator> FusedIterator<I> {
pub fn new(iter: I) -> Self {
Self { iter }
}
}
impl<I: StorageIterator> StorageIterator for FusedIterator<I> {
fn is_valid(&self) -> bool {
unimplemented!()
}
fn key(&self) -> &[u8] {
unimplemented!()
}
fn value(&self) -> &[u8] {
unimplemented!()
}
fn next(&mut self) -> Result<()> {
unimplemented!()
}
}