use crate::{ExtVal, GlobalTime, Lang, ReplicationTag, Sdw};
use serde::{Deserialize, Serialize};
#[serde(bound = "")]
#[derive(Clone, Debug, PartialOrd, Ord, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Entry<L: Lang> {
Delayed(L::Expr, Vec<L::Val>, ReplicationTag),
Settled(ExtVal<L>, ReplicationTag),
Aborted,
}
#[derive(Clone, Default, PartialOrd, Ord, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct KeyVer<L: Lang> {
pub key: L::Key,
pub ver: GlobalTime,
}
impl<L: Lang> std::fmt::Debug for KeyVer<L> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_fmt(format_args!("{:?}:{:?}", self.key, self.ver))
}
}
pub trait Store<L: Lang>: Send + Sync + 'static {
fn get_key_at_or_before_time(&self, kv: &KeyVer<L>) -> Option<(GlobalTime, Entry<L>)>;
fn put_key_at_time(&mut self, kv: &KeyVer<L>, v: &Entry<L>);
fn get_delayed_watermark(&self) -> Option<Sdw>;
}