use derive_more::Debug;

use crate::Record;

pub type UpsertEventFn<Item> = Box<dyn Fn(&<Item as Record>::SelfId, &Item) + Send + Sync>;
pub type RemoveEventFn<Item> = Box<dyn Fn(&<Item as Record>::SelfId) + Send + Sync>;

#[derive(Debug)]
pub(crate) struct LogDbEventHandlers<Item: Record> {
    #[debug("{}", self.on_upsert.is_some())]
    pub(crate) on_upsert: Option<UpsertEventFn<Item>>,
    #[debug("{}", self.on_remove.is_some())]
    pub(crate) on_remove: Option<RemoveEventFn<Item>>,
}

impl<Item: Record> Default for LogDbEventHandlers<Item> {
    fn default() -> Self {
        Self {
            on_upsert: None,
            on_remove: None,
        }
    }
}
