RocksDBProviderFactory

Trait RocksDBProviderFactory 

Source
pub trait RocksDBProviderFactory {
    // Required methods
    fn rocksdb_provider(&self) -> RocksDBProvider;
    fn set_pending_rocksdb_batch(&self, batch: WriteBatchWithTransaction<true>);
    fn commit_pending_rocksdb_batches(&self) -> Result<(), ProviderError>;

    // Provided methods
    fn with_rocksdb_tx<F, R>(&self, f: F) -> Result<R, ProviderError>
       where Self: StorageSettingsCache,
             F: FnOnce(Option<&RocksTx<'_>>) -> Result<R, ProviderError> { ... }
    fn with_rocksdb_batch<F, R>(&self, f: F) -> Result<R, ProviderError>
       where F: FnOnce(RocksDBBatch<'_>) -> Result<(R, Option<WriteBatchWithTransaction<true>>), ProviderError> { ... }
    fn with_rocksdb_batch_auto_commit<F, R>(
        &self,
        f: F,
    ) -> Result<R, ProviderError>
       where F: FnOnce(RocksDBBatch<'_>) -> Result<(R, Option<WriteBatchWithTransaction<true>>), ProviderError> { ... }
}
Available on crate feature provider only.
Expand description

RocksDB provider factory.

This trait provides access to the RocksDB provider

Required Methods§

Source

fn rocksdb_provider(&self) -> RocksDBProvider

Returns the RocksDB provider.

Source

fn set_pending_rocksdb_batch(&self, batch: WriteBatchWithTransaction<true>)

Available on Unix and crate feature rocksdb only.

Adds a pending RocksDB batch to be committed when this provider is committed.

This allows deferring RocksDB commits to happen at the same time as MDBX and static file commits, ensuring atomicity across all storage backends.

Source

fn commit_pending_rocksdb_batches(&self) -> Result<(), ProviderError>

Available on Unix and crate feature rocksdb only.

Takes all pending RocksDB batches and commits them.

This drains the pending batches from the lock and commits each one using the RocksDB provider. Can be called before flush to persist RocksDB writes independently of the full commit path.

Provided Methods§

Source

fn with_rocksdb_tx<F, R>(&self, f: F) -> Result<R, ProviderError>

Executes a closure with a RocksDB transaction for reading.

This helper encapsulates all the cfg-gated RocksDB transaction handling for reads. On legacy MDBX-only nodes (where any_in_rocksdb() is false), this skips creating the RocksDB transaction entirely, avoiding unnecessary overhead.

Source

fn with_rocksdb_batch<F, R>(&self, f: F) -> Result<R, ProviderError>
where F: FnOnce(RocksDBBatch<'_>) -> Result<(R, Option<WriteBatchWithTransaction<true>>), ProviderError>,

Executes a closure with a RocksDB batch, automatically registering it for commit.

This helper encapsulates all the cfg-gated RocksDB batch handling.

Source

fn with_rocksdb_batch_auto_commit<F, R>(&self, f: F) -> Result<R, ProviderError>
where F: FnOnce(RocksDBBatch<'_>) -> Result<(R, Option<WriteBatchWithTransaction<true>>), ProviderError>,

Executes a closure with a RocksDB batch that auto-commits on threshold.

Unlike Self::with_rocksdb_batch, this uses a batch that automatically commits when it exceeds the size threshold, preventing OOM during large bulk writes. The consistency check on startup heals any crash between auto-commits.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§