use std::{
fmt::Debug,
hash::{BuildHasher, Hash},
};
use qbice_stable_hash::BuildStableHasher;
use qbice_stable_type_id::Identifiable;
use qbice_storage::storage_engine::StorageEngine;
pub trait Config:
Identifiable
+ Default
+ Debug
+ Clone
+ Copy
+ PartialEq
+ Eq
+ PartialOrd
+ Ord
+ Hash
+ Send
+ Sync
+ 'static
{
type StorageEngine: StorageEngine;
type BuildStableHasher: BuildStableHasher<Hash = u128>
+ Clone
+ Send
+ Sync
+ 'static;
type BuildHasher: BuildHasher + Default + Clone + Send + Sync + 'static;
}
#[cfg(feature = "default-config")]
mod default_config {
use qbice_stable_type_id::Identifiable;
use qbice_storage::{
kv_database::rocksdb::RocksDB, storage_engine::db_backed::DbBacked,
};
use crate::Config;
#[derive(
Debug,
Clone,
Copy,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
Default,
Identifiable,
)]
pub struct DefaultConfig;
impl Config for DefaultConfig {
type StorageEngine = DbBacked<RocksDB>;
type BuildStableHasher = qbice_stable_hash::SeededStableHasherBuilder<
qbice_stable_hash::Sip128Hasher,
>;
type BuildHasher = fxhash::FxBuildHasher;
}
}
#[cfg(feature = "default-config")]
pub use default_config::DefaultConfig;
pub type SingleMap<C, K, V> =
<<C as Config>::StorageEngine as StorageEngine>::SingleMap<K, V>;
pub type DynamicMap<C, K> =
<<C as Config>::StorageEngine as StorageEngine>::DynamicMap<K>;
pub type KeyOfSetMap<C, K, Con> =
<<C as Config>::StorageEngine as StorageEngine>::KeyOfSetMap<K, Con>;
pub type WriteTransaction<C> =
<<C as Config>::StorageEngine as StorageEngine>::WriteTransaction;