mod block;
mod config;
mod core;
mod recovery;
#[cfg(test)]
mod tests;
use crate::error::{StoreError, StoreResult};
use crate::types::{BlockId, Operation, StoreKey as Key, Value};
pub use block::BlockStoreFacade;
pub use config::{RemoteServerSettings, StoreConfig};
pub use core::SimpleStoreFacade;
pub trait StoreFacade: Send + Sync {
fn set(&self, block_height: BlockId, operations: Vec<Operation>) -> StoreResult<()>;
fn rollback(&self, target: BlockId) -> StoreResult<()>;
fn get(&self, key: Key) -> StoreResult<Value>;
fn multi_get(&self, keys: &[Key]) -> StoreResult<Vec<Value>>;
fn pop(&self, _block_height: BlockId, _key: Key) -> StoreResult<Value> {
pop_not_supported()
}
fn enable_relaxed_mode(&self, _sync_every_n_blocks: usize) -> StoreResult<()> {
relaxed_mode_not_supported()
}
fn relaxed_mode_enabled(&self) -> bool {
false
}
fn disable_relaxed_mode(&self) -> StoreResult<()> {
relaxed_mode_not_supported()
}
fn close(&self) -> StoreResult<()>;
fn current_block(&self) -> StoreResult<BlockId>;
fn applied_block(&self) -> StoreResult<BlockId>;
fn durable_block(&self) -> StoreResult<BlockId>;
fn ensure_healthy(&self) -> StoreResult<()>;
}
fn relaxed_mode_not_supported() -> StoreResult<()> {
Err(StoreError::UnsupportedOperation {
reason: "relaxed durability mode is not supported by this StoreFacade".to_string(),
})
}
fn pop_not_supported() -> StoreResult<Value> {
Err(StoreError::UnsupportedOperation {
reason: "pop is not supported by this StoreFacade".to_string(),
})
}