Struct idb_sys::Database

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

Database provides a connection to a database; you can use an Database object to open a transaction on your database then create, manipulate, and delete objects (data) in that database. The object provides the only way to get and manage versions of the database.

Implementations§

source§

impl Database

source

pub fn name(&self) -> String

Returns the name of the database.

source

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

Returns the version of the database.

source

pub fn store_names(&self) -> Vec<String>

Returns a list of the names of ObjectStores in the database.

source

pub fn transaction<T>( &self, store_names: &[T], mode: TransactionMode ) -> Result<Transaction, Error>
where T: AsRef<str>,

Returns a new transaction with the given scope (which can be a single object store name or an array of names), mode (TransactionMode::ReadOnly or TransactionMode::ReadWrite).

source

pub fn close(&self)

Closes the connection once all running transactions have finished.

source

pub fn create_object_store( &self, name: &str, params: ObjectStoreParams ) -> Result<ObjectStore, Error>

Creates a new object store with the given name and options and returns a new ObjectStore. Returns an Error if not called within an upgrade transaction.

source

pub fn delete_object_store(&self, name: &str) -> Result<(), Error>

Deletes the object store with the given name. Returns an Error if not called within an upgrade transaction.

source

pub fn on_abort<F>(&mut self, callback: F)
where F: FnOnce(Event) + 'static,

Adds an event handler for abort event.

source

pub fn on_close<F>(&mut self, callback: F)
where F: FnOnce(Event) + 'static,

Adds an event handler for close event.

source

pub fn on_error<F>(&mut self, callback: F)
where F: FnOnce(Event) + 'static,

Adds an event handler for error event.

source

pub fn on_version_change<F>(&mut self, callback: F)
where F: FnOnce(Event) + 'static,

Adds an event handler for versionchange event.

Trait Implementations§

source§

impl Debug for Database

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<Database> for IdbDatabase

source§

fn from(database: Database) -> Self

Converts to this type from the input type.
source§

impl From<Database> for JsValue

source§

fn from(value: Database) -> Self

Converts to this type from the input type.
source§

impl From<IdbDatabase> for Database

source§

fn from(inner: IdbDatabase) -> Self

Converts to this type from the input type.
source§

impl TryFrom<EventTarget> for Database

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(target: EventTarget) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<JsValue> for Database

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(value: JsValue) -> Result<Self, Self::Error>

Performs the conversion.

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, U> TryFrom<U> for T
where 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 T
where 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.