Struct grebedb::Database [−][src]
GrebeDB database interface.
Implementations
impl Database[src]
pub fn open(
vfs: Box<dyn Vfs + Sync + Send>,
options: Options
) -> Result<Self, Error>[src]
vfs: Box<dyn Vfs + Sync + Send>,
options: Options
) -> Result<Self, Error>
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]
P: Into<PathBuf>,
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]
K: AsRef<[u8]>,
Return whether the key exists.
pub fn get<K>(&mut self, key: K) -> Result<Option<Vec<u8>>, Error> where
K: AsRef<[u8]>, [src]
K: AsRef<[u8]>,
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]
&mut self,
key: K,
value_destination: &mut Vec<u8>
) -> Result<bool, Error> where
K: AsRef<[u8]>,
Retrieve a stored value, by its key, into the given buffer.
Returns true if the key-value pair was found. The vector will be cleared and resized.
pub fn put<K, V>(&mut self, key: K, value: V) -> Result<(), Error> where
K: Into<Vec<u8>>,
V: Into<Vec<u8>>, [src]
K: Into<Vec<u8>>,
V: Into<Vec<u8>>,
Store a key-value pair.
pub fn remove<K>(&mut self, key: K) -> Result<(), Error> where
K: AsRef<[u8]>, [src]
K: AsRef<[u8]>,
Remove a key-value pair by its key.
No error occurs if the key does not exist.
pub fn cursor(&mut self) -> Result<Cursor<'_>, Error>[src]
Return a cursor for iterating all the key-value pairs.
pub fn cursor_range<K, R>(&mut self, range: R) -> Result<Cursor<'_>, Error> where
K: AsRef<[u8]>,
R: RangeBounds<K>, [src]
K: AsRef<[u8]>,
R: RangeBounds<K>,
Return a cursor for iterating all the key-value pairs within the given range.
This method is equivalent of obtaining a cursor and calling
Cursor::seek() and Cursor::set_range()
pub fn flush(&mut self) -> Result<(), Error>[src]
Persist all modifications to the file system.
Calling this function ensures that all changes pending, whether cached in memory or in files, are atomically saved on the file system before this function returns. If the database is not flushed when dropped or the program exits, changes since the last successful flush will be discarded. This function effectively emulates a transaction.
For details about automatic flushing, see Options.
pub fn verify<P>(&mut self, progress_callback: P) -> Result<(), Error> where
P: FnMut(usize, usize), [src]
P: FnMut(usize, usize),
Check the database for internal consistency and data integrity.
The provided callback function is called with the number of items processed and the estimated number of items.
The function returns an error on the first verification failure or other error.
pub fn debug_print_tree(&mut self) -> Result<(), Error>[src]
Print the tree for debugging purposes.
Trait Implementations
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,