rocksolid 3.0.0

An ergonomic, high-level RocksDB wrapper for Rust. Features CF-aware optimistic & pessimistic transactions, advanced routing for merge operators and compaction filters, performance tuning profiles, batching, TTL values, and DAO macros.
Documentation
//! A minimal seek-capable extension over the raw byte-pair iterators produced by
//! the various `iterate` factories.
//!
//! Every rocksolid iterate path (non-transactional, pessimistic, and optimistic)
//! boxes a `rocksdb::DBIteratorWithThreadMode<'_, D>` as its underlying row source.
//! That high-level iterator can be re-positioned mid-iteration via `set_mode`, which
//! re-seeks the underlying raw iterator and primes it so the *next* `.next()` yields
//! the sought key. `SeekableRows` exposes exactly that capability behind a trait object,
//! letting the shared control loops honour [`crate::types::IterationControlDecision::SeekTo`]
//! without changing which concrete iterator each factory builds.

/// A byte-pair row iterator whose cursor can be jumped forward to a target key.
pub(crate) trait SeekableRows:
  Iterator<Item = Result<(Box<[u8]>, Box<[u8]>), rocksdb::Error>>
{
  /// Reposition the cursor to the first key at or beyond `target` in the
  /// iteration direction. After this call, the next `.next()` yields the key
  /// at that position (if any).
  fn seek_to(&mut self, target: &[u8], reverse: bool);
}

impl<'a, D: rocksdb::DBAccess> SeekableRows for rocksdb::DBIteratorWithThreadMode<'a, D> {
  fn seek_to(&mut self, target: &[u8], reverse: bool) {
    let dir = if reverse {
      rocksdb::Direction::Reverse
    } else {
      rocksdb::Direction::Forward
    };
    self.set_mode(rocksdb::IteratorMode::From(target, dir));
  }
}

/// Forwarding impl so a boxed `dyn SeekableRows` is itself `SeekableRows`
/// (the control loops hold their row source as a trait object).
impl SeekableRows for Box<dyn SeekableRows + '_> {
  fn seek_to(&mut self, target: &[u8], reverse: bool) {
    (**self).seek_to(target, reverse)
  }
}