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§
Required Methods§
Sourcefn storage_kind(&self) -> &'static str
fn storage_kind(&self) -> &'static str
Returns a string that identifies the storage kind
Sourcefn transact(&'s self, write: bool) -> Result<Self::Tx>
fn transact(&'s self, write: bool) -> Result<Self::Tx>
Create a transaction object. Write ops will only be called when write == true
.
Sourcefn range_compact(&'s self, lower: &[u8], upper: &[u8]) -> Result<()>
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.
Sourcefn batch_put<'a>(
&'a self,
data: Box<dyn Iterator<Item = Result<(Vec<u8>, Vec<u8>)>> + 'a>,
) -> Result<()>
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.