pub struct Database { /* private fields */ }
Expand description

Database backed by both IndexedDB and in memory implementation.

Implementations§

source§

impl Database

source

pub async fn open( table_name: &str, columns: u32, memory_cached: bool ) -> Result<Database, Error>

Opens the database with the given name, and the specified number of columns (not including the default one).

source

pub async fn delete(table_name: &str) -> Result<()>

Deletes the database with the given name,

source

pub fn name(&self) -> String

Get the database name.

source

pub fn num_columns(&self) -> Result<u32, Error>

Get the number of columns

source

pub fn version(&self) -> u32

Get the database version.

Trait Implementations§

source§

impl Clone for Database

source§

fn clone(&self) -> Database

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl KeyValueDB for Database

source§

fn get<'a>( &self, col: u32, key: &'a [u8] ) -> Pin<Box<dyn Future<Output = Result<Option<DBValue>>> + Send + 'a>>

Get a value by key.
source§

fn delete<'a>( &self, col: u32, key: &'a [u8] ) -> Pin<Box<dyn Future<Output = Result<Option<DBValue>>> + Send + 'a>>

Remove a value by key, returning the old value
source§

fn write( &self, transaction: DBTransaction ) -> Pin<Box<dyn Future<Output = Result<(), DBTransactionError>> + Send + 'static>>

Write a transaction of changes to the backing store.
source§

fn iter<'a, T: 'a, F: FnMut(DBKeyValueRef<'_>) -> Result<Option<T>> + Send + Sync + 'a>( &self, col: u32, prefix: Option<&'a [u8]>, f: F ) -> Pin<Box<dyn Future<Output = Result<Option<T>>> + Send + 'a>>

Iterate over the data for a given column. Return all key/value pairs, optionally where the key starts with the given prefix. Iterator closure returns true for more items, false to stop iteration.
source§

fn iter_keys<'a, T: 'a, F: FnMut(DBKeyRef<'_>) -> Result<Option<T>> + Send + Sync + 'a>( &self, col: u32, prefix: Option<&'a [u8]>, f: F ) -> Pin<Box<dyn Future<Output = Result<Option<T>>> + Send + 'a>>

Iterate over the data for a given column. Return all keys, optionally where the key starts with the given prefix. Iterator closure returns true for more items, false to stop iteration.
source§

fn restore(&self, _new_db: &str) -> Result<()>

Attempt to replace this database with a new one located at the given path.
source§

fn transaction(&self) -> DBTransaction

Helper to create a new transaction.
source§

fn io_stats(&self, _kind: Kind) -> IoStats

Query statistics. Read more
source§

fn has_key<'a>( &self, col: u32, key: &'a [u8] ) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'a, Global>>

Check for the existence of a value by key.
source§

fn has_prefix<'a>( &self, col: u32, prefix: &'a [u8] ) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'a, Global>>

Check for the existence of a value by prefix.
source§

fn first_with_prefix<'a>( &self, col: u32, prefix: &'a [u8] ) -> Pin<Box<dyn Future<Output = Result<Option<(Vec<u8, Global>, Vec<u8, Global>)>, Error>> + Send + 'a, Global>>

Get the first value matching the given prefix.

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,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.