pub struct IndexManager { /* private fields */ }Expand description
Manages multiple indexes for a database.
The IndexManager provides a centralized way to create, access, and manage indexes across the database. It supports both B-Tree and Hash indexes.
§Example
use rustlite_core::index::{IndexManager, IndexType};
let mut manager = IndexManager::new();
// Create indexes
manager.create_index("users_by_id", IndexType::Hash).unwrap();
manager.create_index("users_by_name", IndexType::BTree).unwrap();
// Use indexes
manager.insert("users_by_id", b"user:1", 100).unwrap();
manager.insert("users_by_name", b"alice", 100).unwrap();Implementations§
Source§impl IndexManager
impl IndexManager
Sourcepub fn create_index(&mut self, name: &str, index_type: IndexType) -> Result<()>
pub fn create_index(&mut self, name: &str, index_type: IndexType) -> Result<()>
Create a new index with the given name and type.
Sourcepub fn drop_index(&mut self, name: &str) -> Result<bool>
pub fn drop_index(&mut self, name: &str) -> Result<bool>
Drop an index by name.
Sourcepub fn get_index_mut(
&mut self,
name: &str,
) -> Option<&mut (dyn Index + 'static)>
pub fn get_index_mut( &mut self, name: &str, ) -> Option<&mut (dyn Index + 'static)>
Get a mutable reference to an index by name.
Sourcepub fn insert(&mut self, name: &str, key: &[u8], value: u64) -> Result<()>
pub fn insert(&mut self, name: &str, key: &[u8], value: u64) -> Result<()>
Insert a key-value pair into a named index.
Sourcepub fn remove(&mut self, name: &str, key: &[u8]) -> Result<bool>
pub fn remove(&mut self, name: &str, key: &[u8]) -> Result<bool>
Remove a key from a named index.
Sourcepub fn list_indexes(&self) -> Vec<&str>
pub fn list_indexes(&self) -> Vec<&str>
List all index names.
Sourcepub fn index_info(&self) -> Vec<IndexInfo>
pub fn index_info(&self) -> Vec<IndexInfo>
Get information about all indexes.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for IndexManager
impl !RefUnwindSafe for IndexManager
impl Send for IndexManager
impl Sync for IndexManager
impl Unpin for IndexManager
impl !UnwindSafe for IndexManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more