Struct grebedb::Database[][src]

pub struct Database { /* fields omitted */ }

GrebeDB database interface.

Implementations

impl Database[src]

pub fn open(
    vfs: Box<dyn Vfs + Sync + Send>,
    options: Options
) -> Result<Self, Error>
[src]

Open a database using the given virtual file system and options.

pub fn open_memory(options: Options) -> Result<Self, Error>[src]

Open a database in temporary memory.

pub fn open_path<P>(root_path: P, options: Options) -> Result<Self, Error> where
    P: Into<PathBuf>, 
[src]

Open a database to a path on the disk.

The path must be a directory.

pub fn metadata(&self) -> Metadata<'_>[src]

Return database metadata information.

pub fn contains_key<K>(&mut self, key: K) -> Result<bool, Error> where
    K: AsRef<[u8]>, 
[src]

Return whether the key exists.

pub fn get<K>(&mut self, key: K) -> Result<Option<Vec<u8>>, Error> where
    K: AsRef<[u8]>, 
[src]

Retrieve a stored value, by its key, as a vector.

pub fn get_buf<K>(
    &mut self,
    key: K,
    value_destination: &mut Vec<u8>
) -> Result<bool, Error> where
    K: AsRef<[u8]>, 
[src]

Retrieve a stored value, by its key, into the given buffer.

Returns true if the key-value pair was found.

pub fn put<K, V>(&mut self, key: K, value: V) -> Result<(), Error> where
    K: Into<Vec<u8>>,
    V: Into<Vec<u8>>, 
[src]

Store a key-value pair.

pub fn remove<K>(&mut self, key: K) -> Result<(), Error> where
    K: AsRef<[u8]>, 
[src]

Remove a key-value pair by its key.

No error occurs if the key does not exist.

pub fn cursor(&mut self) -> Cursor<'_>

Notable traits for Cursor<'a>

impl<'a> Iterator for Cursor<'a> type Item = KeyValuePair;
[src]

Return a cursor for iterating all the key-value pairs.

pub fn cursor_range<K1, K2>(
    &mut self,
    start: Option<K1>,
    end: Option<K2>
) -> Result<Cursor<'_>, Error> where
    K1: AsRef<[u8]>,
    K2: Into<Vec<u8>>, 
[src]

Return a cursor for iterating all the key-value pairs within the given range.

This method is equivalent of obtaining a cursor and setting Cursor::seek() and Cursor::set_range_end()

pub fn flush(&mut self) -> Result<(), Error>[src]

Persist all internally cached data to the file system.

Calling this function ensures that all modifications cached in memory are written to the file system before this function returns.

For details about automatic flushing, see Options.

pub fn debug_print_tree(&mut self) -> Result<(), Error>[src]

Print the tree for debugging purposes.

Trait Implementations

impl Debug for Database[src]

impl Drop for Database[src]

Auto Trait Implementations

impl !RefUnwindSafe for Database

impl Send for Database

impl Sync for Database

impl Unpin for Database

impl !UnwindSafe for Database

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.