use std::sync::OnceLock;
use crate::core::schema::{IndexDesc, IndexKey, TableId};
pub trait Versioned: Sized + Clone + Send + Sync + 'static {
type Key: Ord + Clone + core::hash::Hash + Send + Sync + 'static;
const TABLE_NAME: &'static str;
fn table_id_cell() -> &'static OnceLock<TableId>;
fn table_id() -> TableId {
*Self::table_id_cell().get().unwrap_or_else(|| {
panic!(
"`{}` was not registered: call `db.register::<{}>()` before using it",
Self::TABLE_NAME,
Self::TABLE_NAME,
)
})
}
fn key(&self) -> Self::Key;
fn key_bytes(&self) -> IndexKey;
fn indexes() -> &'static [IndexDesc<Self>];
}