use tracing::Level;
use crate::storage::HasStorage;
use crate::{Database, Storage};
#[derive(Clone)]
pub struct DatabaseImpl {
storage: Storage<Self>,
}
impl Default for DatabaseImpl {
fn default() -> Self {
Self {
storage: Storage::new(if tracing::enabled!(Level::DEBUG) {
Some(Box::new(|event| {
crate::tracing::debug!("salsa_event({:?})", event)
}))
} else {
None
}),
}
}
}
impl DatabaseImpl {
pub fn new() -> Self {
Self::default()
}
pub fn storage(&self) -> &Storage<Self> {
&self.storage
}
}
impl Database for DatabaseImpl {}
unsafe impl HasStorage for DatabaseImpl {
#[inline(always)]
fn storage(&self) -> &Storage<Self> {
&self.storage
}
#[inline(always)]
fn storage_mut(&mut self) -> &mut Storage<Self> {
&mut self.storage
}
}