use oasis_core_runtime::storage::mkvs::Iterator;
pub mod confidential;
mod hashed;
mod host;
mod mkvs;
mod overlay;
mod prefix;
mod typed;
pub trait Store {
fn get(&self, key: &[u8]) -> Option<Vec<u8>>;
fn insert(&mut self, key: &[u8], value: &[u8]);
fn remove(&mut self, key: &[u8]);
fn iter(&self) -> Box<dyn Iterator + '_>;
fn prefetch_prefixes(&mut self, prefixes: Vec<Prefix>, limit: u16);
}
pub trait NestedStore: Store {
type Inner;
fn commit(self) -> Self::Inner;
fn rollback(self) -> Self::Inner;
fn has_pending_updates(&self) -> bool;
fn pending_update_byte_size(&self) -> usize;
}
impl<S: Store + ?Sized> Store for &mut S {
fn get(&self, key: &[u8]) -> Option<Vec<u8>> {
S::get(self, key)
}
fn insert(&mut self, key: &[u8], value: &[u8]) {
S::insert(self, key, value)
}
fn remove(&mut self, key: &[u8]) {
S::remove(self, key)
}
fn iter(&self) -> Box<dyn Iterator + '_> {
S::iter(self)
}
fn prefetch_prefixes(&mut self, prefixes: Vec<Prefix>, limit: u16) {
S::prefetch_prefixes(self, prefixes, limit)
}
}
impl<S: Store + ?Sized> Store for Box<S> {
fn get(&self, key: &[u8]) -> Option<Vec<u8>> {
S::get(self, key)
}
fn insert(&mut self, key: &[u8], value: &[u8]) {
S::insert(self, key, value)
}
fn remove(&mut self, key: &[u8]) {
S::remove(self, key)
}
fn iter(&self) -> Box<dyn Iterator + '_> {
S::iter(self)
}
fn prefetch_prefixes(&mut self, prefixes: Vec<Prefix>, limit: u16) {
S::prefetch_prefixes(self, prefixes, limit)
}
}
pub use confidential::{ConfidentialStore, Error as ConfidentialStoreError};
pub use hashed::HashedStore;
pub use host::HostStore;
pub use mkvs::MKVSStore;
pub use overlay::OverlayStore;
pub use prefix::PrefixStore;
pub use typed::TypedStore;
pub use oasis_core_runtime::storage::mkvs::Prefix;