pub trait Index: Send + Sync {
// Required methods
fn insert(&mut self, key: &[u8], value: u64) -> Result<()>;
fn find(&self, key: &[u8]) -> Result<Vec<u64>>;
fn remove(&mut self, key: &[u8]) -> Result<bool>;
fn len(&self) -> usize;
fn clear(&mut self);
fn index_type(&self) -> IndexType;
// Provided method
fn is_empty(&self) -> bool { ... }
}Expand description
Index trait defining the common interface for all index types
Required Methods§
Sourcefn insert(&mut self, key: &[u8], value: u64) -> Result<()>
fn insert(&mut self, key: &[u8], value: u64) -> Result<()>
Insert a key-value pair into the index. The value is typically a pointer/offset to the actual data.
Sourcefn remove(&mut self, key: &[u8]) -> Result<bool>
fn remove(&mut self, key: &[u8]) -> Result<bool>
Remove all entries for a key from the index. Returns true if any entries were removed.
Sourcefn index_type(&self) -> IndexType
fn index_type(&self) -> IndexType
Returns the index type.