Skip to main content

StorageWriteBatch

Trait StorageWriteBatch 

Source
pub trait StorageWriteBatch: Send {
    // Required methods
    fn put_batch(
        &mut self,
        table: &'static str,
        batch: Vec<(Vec<u8>, Vec<u8>)>,
    ) -> Result<(), StoreError>;
    fn delete(
        &mut self,
        table: &'static str,
        key: &[u8],
    ) -> Result<(), StoreError>;
    fn merge(
        &mut self,
        table: &'static str,
        key: &[u8],
        operand: &[u8],
    ) -> Result<(), StoreError>;
    fn commit(&mut self) -> Result<(), StoreError>;

    // Provided method
    fn put(
        &mut self,
        table: &'static str,
        key: &[u8],
        value: &[u8],
    ) -> Result<(), StoreError> { ... }
}
Expand description

Write transaction interface.

Note that this does not provide read access, since we don’t currently use that functionality.

Changes are not persisted until commit() is called.

Required Methods§

Source

fn put_batch( &mut self, table: &'static str, batch: Vec<(Vec<u8>, Vec<u8>)>, ) -> Result<(), StoreError>

Stores multiple key-value pairs in the specified table within the transaction.

Source

fn delete(&mut self, table: &'static str, key: &[u8]) -> Result<(), StoreError>

Removes a key-value pair from the specified table.

Source

fn merge( &mut self, table: &'static str, key: &[u8], operand: &[u8], ) -> Result<(), StoreError>

Appends a merge operand for the given key in the specified table.

The actual combine step is deferred — backends with a registered merge operator (RocksDB) apply it at read or compaction time; backends without (InMemory) dispatch by table and apply inline.

Currently used for TRANSACTION_LOCATIONS. Calling on a table without a registered merge function is an error.

Source

fn commit(&mut self) -> Result<(), StoreError>

Commits all changes made in this transaction.

Provided Methods§

Source

fn put( &mut self, table: &'static str, key: &[u8], value: &[u8], ) -> Result<(), StoreError>

Stores a key-value pair in the specified table.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§