pub struct DiskOrderedCursor<'env> { /* private fields */ }Expand description
A cursor that returns records in on-disk order rather than key order.
See the module-level docs for trade-offs and consistency guarantees.
§Lifetime
The lifetime parameter 'env ties the cursor to the borrow of the
Database slice passed to Database::open_disk_ordered_cursor and
open_disk_ordered_cursor_multi, preventing the application from
closing a database while the cursor is still scanning.
§Example
use noxu_db::{DatabaseEntry, DiskOrderedCursorConfig, OperationStatus};
let mut cursor = db.open_disk_ordered_cursor(
DiskOrderedCursorConfig::new().with_queue_size(64),
)?;
let mut key = DatabaseEntry::new();
let mut data = DatabaseEntry::new();
while cursor.next(&mut key, &mut data)? == OperationStatus::Success {
// ...process key + data...
}
cursor.close()?;Implementations§
Source§impl<'env> DiskOrderedCursor<'env>
impl<'env> DiskOrderedCursor<'env>
Sourcepub fn next(
&mut self,
key: &mut DatabaseEntry,
data: &mut DatabaseEntry,
) -> Result<OperationStatus>
pub fn next( &mut self, key: &mut DatabaseEntry, data: &mut DatabaseEntry, ) -> Result<OperationStatus>
Advances the cursor to the next record.
On Ok(Success) the key and data DatabaseEntrys are populated
with the next record’s bytes. On Ok(NotFound) the cursor has
reached end-of-log and no further records will be returned (it is
safe — and idempotent — to call again).
§Errors
NoxuError::CursorClosedifSelf::closehas been called.NoxuError::IoError/NoxuError::LogChecksumMismatchif the producer thread reported a permanent log-read error.
Sourcepub fn current(
&self,
key: &mut DatabaseEntry,
data: &mut DatabaseEntry,
) -> Result<OperationStatus>
pub fn current( &self, key: &mut DatabaseEntry, data: &mut DatabaseEntry, ) -> Result<OperationStatus>
Returns the most recent record yielded by Self::next without
advancing.
Returns OperationStatus::NotFound if the cursor has not yet been
advanced or has reached end-of-log.
Sourcepub fn close(self) -> Result<()>
pub fn close(self) -> Result<()>
Closes the cursor, signalling and joining the producer thread.
Idempotent — calling close on an already-closed cursor is a no-op
and returns Ok(()). This is also called automatically when the
cursor is dropped, so applications using RAII can rely on the drop
glue rather than calling close explicitly.