Struct Factory

Source
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>

Source

pub fn get() -> Result<Factory<Err>, Err>

Retrieve the global Factory from the browser

This internally uses indexedDB.

Source

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.

Source

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

Source

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

Source

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

Trait Implementations§

Source§

impl<Err: Debug> Debug for Factory<Err>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Err> Freeze for Factory<Err>

§

impl<Err> RefUnwindSafe for Factory<Err>
where Err: RefUnwindSafe,

§

impl<Err> !Send for Factory<Err>

§

impl<Err> !Sync for Factory<Err>

§

impl<Err> Unpin for Factory<Err>
where Err: Unpin,

§

impl<Err> UnwindSafe for Factory<Err>
where Err: UnwindSafe,

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>,

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.