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]
Expand description
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]
path: Option<&Path>,
secondary_path: Option<&Path>
) -> Result<Self, StorageError>
Expand description
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]
Expand description
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]
Expand description
Returns all the keys and values belonging to the given column.
fn get_keys(&self, col: u32) -> Result<Vec<Box<[u8]>>, StorageError>[src]
Expand description
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]
&self,
col: u32,
key: K,
value: V
) -> Result<(), StorageError>
Expand description
Stores the given key and value in the specified column.
fn batch(&self, batch: DatabaseTransaction) -> Result<(), StorageError>[src]
Expand description
Executes the given DatabaseTransaction as a batch operation.
fn exists(&self, col: u32, key: &[u8]) -> bool[src]
Expand description
Returns true if the given key exists in the speficied column.