Trait Storage

Source
pub trait Storage<'s>:
    Send
    + Sync
    + Clone {
    type Tx: StoreTx<'s>;

    // Required methods
    fn storage_kind(&self) -> &'static str;
    fn transact(&'s self, write: bool) -> Result<Self::Tx>;
    fn range_compact(&'s self, lower: &[u8], upper: &[u8]) -> Result<()>;
    fn batch_put<'a>(
        &'a self,
        data: Box<dyn Iterator<Item = Result<(Vec<u8>, Vec<u8>)>> + 'a>,
    ) -> Result<()>;
}
Expand description

Swappable storage trait for Cozo’s storage engine

Required Associated Types§

Source

type Tx: StoreTx<'s>

The associated transaction type used by this engine

Required Methods§

Source

fn storage_kind(&self) -> &'static str

Returns a string that identifies the storage kind

Source

fn transact(&'s self, write: bool) -> Result<Self::Tx>

Create a transaction object. Write ops will only be called when write == true.

Source

fn range_compact(&'s self, lower: &[u8], upper: &[u8]) -> Result<()>

Compact the key range. Can be a no-op if the storage engine does not have the concept of compaction.

Source

fn batch_put<'a>( &'a self, data: Box<dyn Iterator<Item = Result<(Vec<u8>, Vec<u8>)>> + 'a>, ) -> Result<()>

Put multiple key-value pairs into the database. No duplicate data will be sent, and the order data come in is strictly ascending. There will be no other access to the database while this function is running.

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§

Source§

impl<'s> Storage<'s> for MemStorage

Source§

type Tx = MemTx<'s>

Source§

impl<'s> Storage<'s> for SqliteStorage

Source§

type Tx = SqliteTx<'s>