Trait snarkvm_objects::traits::storage::Storage[][src]

pub trait Storage where
    Self: Sized
{ const IN_MEMORY: bool; fn open(
        path: Option<&Path>,
        secondary_path: Option<&Path>
    ) -> Result<Self, StorageError>;
fn get(&self, col: u32, key: &[u8]) -> Result<Option<Vec<u8>>, StorageError>;
fn get_col(
        &self,
        col: u32
    ) -> Result<Vec<(Box<[u8]>, Box<[u8]>)>, StorageError>;
fn get_keys(&self, col: u32) -> Result<Vec<Box<[u8]>>, StorageError>;
fn put<K: AsRef<[u8]>, V: AsRef<[u8]>>(
        &self,
        col: u32,
        key: K,
        value: V
    ) -> Result<(), StorageError>;
fn batch(&self, batch: DatabaseTransaction) -> Result<(), StorageError>;
fn exists(&self, col: u32, key: &[u8]) -> bool;
fn try_catch_up_with_primary(&self) -> Result<(), StorageError>; }

Associated Constants

const IN_MEMORY: bool[src]

A bool indicating whether the storage is in-memory only.

Required methods

fn open(
    path: Option<&Path>,
    secondary_path: Option<&Path>
) -> Result<Self, StorageError>
[src]

Opens the storage object, optionally using the given paths; it gets created if it doesn’t exist.

fn get(&self, col: u32, key: &[u8]) -> Result<Option<Vec<u8>>, StorageError>[src]

Returns the value with the given key and belonging to the given column.

fn get_col(&self, col: u32) -> Result<Vec<(Box<[u8]>, Box<[u8]>)>, StorageError>[src]

Returns all the keys and values belonging to the given column.

fn get_keys(&self, col: u32) -> Result<Vec<Box<[u8]>>, StorageError>[src]

Returns all the keys belonging to the given column.

fn put<K: AsRef<[u8]>, V: AsRef<[u8]>>(
    &self,
    col: u32,
    key: K,
    value: V
) -> Result<(), StorageError>
[src]

Stores the given key and value in the specified column.

fn batch(&self, batch: DatabaseTransaction) -> Result<(), StorageError>[src]

Executes the given DatabaseTransaction as a batch operation.

fn exists(&self, col: u32, key: &[u8]) -> bool[src]

Returns true if the given key exists in the speficied column.

fn try_catch_up_with_primary(&self) -> Result<(), StorageError>[src]

Implementors