Struct TransactionBuilder

Source
pub struct TransactionBuilder<Err> { /* private fields */ }
Expand description

Helper to build a transaction

Implementations§

Source§

impl<Err> TransactionBuilder<Err>

Source

pub fn rw(self) -> Self

Allow writes in this transaction

Without this, the transaction will only be allowed reads, and will error upon trying to write objects.

Source

pub async fn run<Fun, RetFut, Ret>(self, transaction: Fun) -> Result<Ret, Err>
where Fun: 'static + FnOnce(Transaction<Err>) -> RetFut, RetFut: 'static + Future<Output = Result<Ret, Err>>, Ret: 'static, Err: 'static,

Actually execute the transaction

The transaction argument defines what will be run in the transaction. Note that due to limitations of the IndexedDb API, the future returned by transaction cannot call .await on any future except the ones provided by the Transaction itself. This function will do its best to detect these cases to abort the transaction and panic, but you should avoid doing so anyway. Note also that these errors are not recoverable: even if wasm32 were not having panic=abort, once there is such a panic no indexed-db functions will work any longer.

If transaction returns an Ok value, then the transaction will be committed. If it returns an Err value, then it will be aborted.

Note that you should avoid sending requests that you do not await. If you do, it is hard to say whether the transaction will commit or abort, due to both the IndexedDB and the wasm-bindgen semantics.

Note that transactions cannot be nested.

Internally, this uses IDBDatabase::transaction.

Auto Trait Implementations§

§

impl<Err> Freeze for TransactionBuilder<Err>

§

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

§

impl<Err> !Send for TransactionBuilder<Err>

§

impl<Err> !Sync for TransactionBuilder<Err>

§

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

§

impl<Err> UnwindSafe for TransactionBuilder<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.