pub struct Factory<Err> { /* private fields */ }
Expand description
Wrapper for IDBFactory
Note that it is quite likely that type inference will fail on the Err
generic argument here.
This argument is the type of user-defined errors that will be passed through transactions and
callbacks.
You should set it to whatever error type your program uses around the indexed-db
-using code.
Implementations§
Source§impl<Err: 'static> Factory<Err>
impl<Err: 'static> Factory<Err>
Sourcepub fn get() -> Result<Factory<Err>, Err>
pub fn get() -> Result<Factory<Err>, Err>
Retrieve the global Factory
from the browser
This internally uses indexedDB
.
Sourcepub fn cmp(&self, lhs: &JsValue, rhs: &JsValue) -> Result<Ordering, Err>
pub fn cmp(&self, lhs: &JsValue, rhs: &JsValue) -> Result<Ordering, Err>
Compare two keys for ordering
Returns an error if one of the two values would not be a valid IndexedDb key.
This internally uses IDBFactory::cmp
.
Sourcepub async fn delete_database(&self, name: &str) -> Result<(), Err>
pub async fn delete_database(&self, name: &str) -> Result<(), Err>
Delete a database
Returns an error if something failed during the deletion. Note that trying to delete a database that does not exist will result in a successful result.
This internally uses IDBFactory::deleteDatabase
Sourcepub async fn open<Fun, RetFut>(
&self,
name: &str,
version: u32,
on_upgrade_needed: Fun,
) -> Result<Database<Err>, Err>where
Fun: 'static + FnOnce(VersionChangeEvent<Err>) -> RetFut,
RetFut: 'static + Future<Output = Result<(), Err>>,
pub async fn open<Fun, RetFut>(
&self,
name: &str,
version: u32,
on_upgrade_needed: Fun,
) -> Result<Database<Err>, Err>where
Fun: 'static + FnOnce(VersionChangeEvent<Err>) -> RetFut,
RetFut: 'static + Future<Output = Result<(), Err>>,
Open a database
Returns an error if something failed while opening or upgrading the database. Blocks until it can actually open the database.
Note that version
must be at least 1
. on_upgrade_needed
will be called when version
is higher
than the previous database version, or upon database creation.
This internally uses IDBFactory::open
as well as the methods from IDBOpenDBRequest
Sourcepub async fn open_latest_version(
&self,
name: &str,
) -> Result<Database<Err>, Err>
pub async fn open_latest_version( &self, name: &str, ) -> Result<Database<Err>, Err>
Open a database at the latest version
Returns an error if something failed while opening. Blocks until it can actually open the database.
This internally uses IDBFactory::open
as well as the methods from IDBOpenDBRequest