Skip to content

Commit

Permalink
Add storage ScanIterator trait
Browse files Browse the repository at this point in the history
  • Loading branch information
erikgrinaker committed Jan 7, 2024
1 parent 0a5ec27 commit 30ac184
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/storage/engine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use serde::{Deserialize, Serialize};
pub trait Engine: std::fmt::Display + Send + Sync {
/// The iterator returned by scan(). Traits can't return "impl Trait", and
/// we don't want to use trait objects, so the type must be specified.
type ScanIterator<'a>: DoubleEndedIterator<Item = Result<(Vec<u8>, Vec<u8>)>> + 'a
type ScanIterator<'a>: ScanIterator + 'a
where
Self: 'a;

Expand Down Expand Up @@ -55,6 +55,11 @@ pub trait Engine: std::fmt::Display + Send + Sync {
fn status(&mut self) -> Result<Status>;
}

/// A scan iterator, with a blanket implementation (in lieu of trait aliases).
pub trait ScanIterator: DoubleEndedIterator<Item = Result<(Vec<u8>, Vec<u8>)>> {}

impl<I: DoubleEndedIterator<Item = Result<(Vec<u8>, Vec<u8>)>>> ScanIterator for I {}

/// Engine status.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct Status {
Expand Down

0 comments on commit 30ac184

Please sign in to comment.