indexed-db
Bindings for IndexedDB, that default transaction to aborting.
Why yet another IndexedDB crate?
As of the time of my writing this crate, the alternatives have the default IndexedDB behavior of transaction committing. This is because IndexedDB transactions have strange committing semantics: they commit as soon as the application returns to the event loop without an ongoing request.
This crate forces your transactions to respect the IndexedDB requirements, so as to make it possible to abort transactions upon errors, rather than having them auto-commit.
Error handling
This crate uses an Error<Err>
type. The Err
generic argument is present on basically all the structs exposed by this crate. It is the type of users in code surrounding indexed-db
usage, for convenience.
In particular, if you ever want to recover one of your own errors (of type Err
) that went through indexed-db
code, you should just match the error with Error::User(_)
, and you will be able to recover your own error details.
On the other hand, when one of your callbacks wants to return an error of your own type through indexed-db
, it can just use the From<Err> for Error<Err>
implementation. This is done automatically by the ?
operator, or can be done manually for explicit returns with return Err(e.into());
.
Example
use Context;
use Factory;
use JsString;
async