Skip to main content

DatabaseWriter

Trait DatabaseWriter 

Source
pub trait DatabaseWriter: DatabaseReader {
    // Required methods
    fn put(&mut self, key: &[u8], value: &[u8]) -> Result<(), DatabaseError>;
    fn overwrite(
        &mut self,
        key: &[u8],
        value: &[u8],
    ) -> Result<(), DatabaseError>;
    fn delete(&mut self, key: &[u8]) -> Result<(), DatabaseError>;
    fn index_put(
        &mut self,
        index: &str,
        key: &[u8],
        value: &[u8],
    ) -> Result<(), DatabaseError>;
    fn index_delete(
        &mut self,
        index: &str,
        key: &[u8],
    ) -> Result<(), DatabaseError>;
    fn commit(self: Box<Self>) -> Result<(), DatabaseError>;
    fn as_reader(&self) -> &dyn DatabaseReader;
}
Expand description

A DatabaseReader provides read access to a database instance.

Required Methods§

Source

fn put(&mut self, key: &[u8], value: &[u8]) -> Result<(), DatabaseError>

Writes the given key/value pair. If the key/value pair already exists, it will return a DatabaseError::DuplicateEntry.

Source

fn overwrite(&mut self, key: &[u8], value: &[u8]) -> Result<(), DatabaseError>

Writes the given key/value pair. If the key/value pair already exists, it overwrites the old value

Source

fn delete(&mut self, key: &[u8]) -> Result<(), DatabaseError>

Deletes the given key/value pair. If the key does exist, it returns an error,

Source

fn index_put( &mut self, index: &str, key: &[u8], value: &[u8], ) -> Result<(), DatabaseError>

Writes the given key/value pair at index.

Source

fn index_delete(&mut self, index: &str, key: &[u8]) -> Result<(), DatabaseError>

Deletes the given key/value pair at index.

Source

fn commit(self: Box<Self>) -> Result<(), DatabaseError>

Source

fn as_reader(&self) -> &dyn DatabaseReader

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§