use std::any::TypeId;
use std::fmt::{Debug, Display};
use std::hash::Hash;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum IndexType {
Hash,
Range,
FullText,
}
impl Display for IndexType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
IndexType::Hash => write!(f, "hash"),
IndexType::Range => write!(f, "range"),
IndexType::FullText => write!(f, "full text"),
}
}
}
pub trait Index
where
Self: Sized + Copy + Eq + Hash + Debug,
{
fn ty(&self) -> TypeId;
fn ordinal(&self) -> usize;
fn index_type(&self) -> IndexType;
}
impl Index for () {
fn ty(&self) -> TypeId {
unimplemented!("index not implemented")
}
fn ordinal(&self) -> usize {
unimplemented!("index not implemented")
}
fn index_type(&self) -> IndexType {
unimplemented!("index not implemented")
}
}