Struct Database

Source
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(name: String, columns: u32) -> Result<Database, Error>

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

Source

pub fn name(&self) -> &str

Get the database name.

Source

pub fn version(&self) -> u32

Get the database version.

Trait Implementations§

Source§

impl Drop for Database

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl KeyValueDB for Database

Source§

fn get(&self, col: u32, key: &[u8]) -> Result<Option<DBValue>>

Get a value by key.
Source§

fn get_by_prefix(&self, col: u32, prefix: &[u8]) -> Option<Box<[u8]>>

Get the first value matching the given prefix.
Source§

fn write(&self, transaction: DBTransaction) -> Result<()>

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

fn iter<'a>( &'a self, col: u32, ) -> Box<dyn Iterator<Item = (Box<[u8]>, Box<[u8]>)> + 'a>

Iterate over the data for a given column.
Source§

fn iter_with_prefix<'a>( &'a self, col: u32, prefix: &'a [u8], ) -> Box<dyn Iterator<Item = (Box<[u8]>, Box<[u8]>)> + 'a>

Iterate over the data for a given column, returning all key/value pairs where the key starts with the given prefix.
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(&self, col: u32, key: &[u8]) -> Result<bool, Error>

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

fn has_prefix(&self, col: u32, prefix: &[u8]) -> bool

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

impl MallocSizeOf for Database

Source§

fn size_of(&self, _: &mut MallocSizeOfOps) -> usize

Measure the heap usage of all descendant heap-allocated structures, but not the space taken up by the value itself. If T::size_of is a constant, consider implementing constant_size as well.
Source§

fn constant_size() -> Option<usize>

Used to optimize MallocSizeOf implementation for collections like Vec and HashMap to avoid iterating over them unnecessarily. The Self: Sized bound is for object safety.

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> MallocSizeOfExt for T
where T: MallocSizeOf,

Source§

fn malloc_size_of(&self) -> usize

Method to launch a heapsize measurement with a fresh state.
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.