Struct simpledb::Database

source ·
pub struct Database {
    pub path: String,
    pub rocksdb: DB,
    pub options: Options,
    /* private fields */
}
Expand description

Database instance.

Fields§

§path: String§rocksdb: DB§options: Options

Implementations§

source§

impl Database

source

pub fn open(path: impl AsRef<Path>) -> Result<Database>

Open database with default options.

source

pub fn open_with_options( path: impl AsRef<Path>, options: Options ) -> Result<Database>

Open database with specific options.

source

pub fn destroy(path: impl AsRef<Path>) -> Result<()>

Destroy database.

source

pub fn save_meta( &self, key: impl AsRef<[u8]>, meta: &KeyMeta, delete_if_empty: bool ) -> Result<()>

source

pub fn get_meta(&self, key: impl AsRef<[u8]>) -> Result<Option<KeyMeta>>

source

pub fn get_or_create_meta( &self, key: impl AsRef<[u8]>, key_type: KeyType ) -> Result<KeyMeta>

source

pub fn for_each_key<F>(&self, f: F) -> Result<usize>where F: FnMut(&str, &KeyMeta) -> bool,

source

pub fn for_each_key_with_limit<F>(&self, limit: usize, f: F) -> Result<usize>where F: FnMut(&str, &KeyMeta) -> bool,

source

pub fn for_each_key_with_prefix<F>(&self, prefix: &str, f: F) -> Result<usize>where F: FnMut(&str, &KeyMeta) -> bool,

source

pub fn keys(&self) -> Result<Vec<(String, KeyMeta)>>

source

pub fn keys_with_prefix(&self, prefix: &str) -> Result<Vec<(String, KeyMeta)>>

source

pub fn for_each_data<F>( &self, key: &str, prefix: Option<&str>, f: F ) -> Result<u64>where F: FnMut(Box<[u8]>, Box<[u8]>) -> bool,

source

pub fn get_count(&self, key: impl AsRef<[u8]>) -> Result<u64>

source

pub fn delete_all(&self, key: &str) -> Result<u64>

source

pub fn map_count(&self, key: impl AsRef<[u8]>) -> Result<u64>

source

pub fn map_get( &self, key: impl AsRef<[u8]>, field: impl AsRef<[u8]> ) -> Result<Option<Vec<u8>>>

source

pub fn map_put( &self, key: impl AsRef<[u8]>, field: impl AsRef<[u8]>, value: impl AsRef<[u8]> ) -> Result<()>

source

pub fn map_delete( &self, key: impl AsRef<[u8]>, field: impl AsRef<[u8]> ) -> Result<bool>

source

pub fn map_for_each<F>(&self, key: &str, f: F) -> Result<u64>where F: FnMut(&str, Box<[u8]>) -> bool,

source

pub fn map_items(&self, key: &str) -> Result<Vec<(String, Box<[u8]>)>>

source

pub fn map_for_each_with_prefix<F>( &self, key: &str, prefix: &str, f: F ) -> Result<u64>where F: FnMut(&str, Box<[u8]>) -> bool,

source

pub fn map_items_with_prefix( &self, key: &str, prefix: &str ) -> Result<Vec<(String, Box<[u8]>)>>

source

pub fn set_count(&self, key: &str) -> Result<u64>

source

pub fn set_add(&self, key: &str, value: &[u8]) -> Result<bool>

source

pub fn set_is_member(&self, key: &str, value: &[u8]) -> Result<bool>

source

pub fn set_delete(&self, key: &str, value: &[u8]) -> Result<bool>

source

pub fn set_for_each<F>(&self, key: &str, f: F) -> Result<u64>where F: FnMut(Box<[u8]>) -> bool,

source

pub fn set_items(&self, key: &str) -> Result<Vec<Box<[u8]>>>

source

pub fn list_count(&self, key: &str) -> Result<u64>

source

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

source

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

source

pub fn list_left_pop(&self, key: &str) -> Result<Option<Box<[u8]>>>

source

pub fn list_right_pop(&self, key: &str) -> Result<Option<Box<[u8]>>>

source

pub fn list_for_each<F>(&self, key: &str, f: F) -> Result<u64>where F: FnMut(Box<[u8]>) -> bool,

source

pub fn list_items(&self, key: &str) -> Result<Vec<Box<[u8]>>>

source

pub fn sorted_list_count(&self, key: &str) -> Result<u64>

source

pub fn sorted_list_add(&self, key: &str, score: &[u8], value: &[u8]) -> Result<u64>

source

pub fn sorted_list_left_pop( &self, key: &str, max_score: Option<&[u8]> ) -> Result<Option<ScoreVal>>

source

pub fn sorted_list_right_pop( &self, key: &str, min_score: Option<&[u8]> ) -> Result<Option<ScoreVal>>

source

pub fn sorted_list_for_each<F>(&self, key: &str, f: F) -> Result<u64>where F: FnMut((Box<[u8]>, Box<[u8]>)) -> bool,

source

pub fn sorted_list_items(&self, key: &str) -> Result<VecScoreVal>

source

pub fn sorted_set_count(&self, key: &str) -> Result<u64>

source

pub fn sorted_set_for_each<F>(&self, key: &str, f: F) -> Result<u64>where F: FnMut((Box<[u8]>, Box<[u8]>)) -> bool,

source

pub fn sorted_set_items(&self, key: &str) -> Result<VecScoreVal>

source

pub fn sorted_set_add(&self, key: &str, score: &[u8], value: &[u8]) -> Result<u64>

source

pub fn sorted_set_is_member(&self, key: &str, value: &[u8]) -> Result<bool>

source

pub fn sorted_set_delete(&self, key: &str, value: &[u8]) -> Result<bool>

source

pub fn sorted_set_left( &self, key: &str, max_score: Option<&[u8]>, limit: usize ) -> Result<VecScoreVal>

source

pub fn sorted_set_right( &self, key: &str, min_score: Option<&[u8]>, limit: usize ) -> Result<VecScoreVal>

Trait Implementations§

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.