IndexManager

Struct IndexManager 

Source
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

Source

pub fn new() -> Self

Create a new empty index manager.

Source

pub fn create_index(&mut self, name: &str, index_type: IndexType) -> Result<()>

Create a new index with the given name and type.

Source

pub fn drop_index(&mut self, name: &str) -> Result<bool>

Drop an index by name.

Source

pub fn get_index(&self, name: &str) -> Option<&dyn Index>

Get a reference to an index by name.

Source

pub fn get_index_mut( &mut self, name: &str, ) -> Option<&mut (dyn Index + 'static)>

Get a mutable reference to an index by name.

Source

pub fn insert(&mut self, name: &str, key: &[u8], value: u64) -> Result<()>

Insert a key-value pair into a named index.

Source

pub fn find(&self, name: &str, key: &[u8]) -> Result<Vec<u64>>

Find values in a named index.

Source

pub fn remove(&mut self, name: &str, key: &[u8]) -> Result<bool>

Remove a key from a named index.

Source

pub fn list_indexes(&self) -> Vec<&str>

List all index names.

Source

pub fn index_info(&self) -> Vec<IndexInfo>

Get information about all indexes.

Trait Implementations§

Source§

impl Default for IndexManager

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.