Transaction

Struct Transaction 

Source
pub struct Transaction { /* private fields */ }
Expand description

Provides a transaction on a database. All reading and writing of data is done within transactions.

Implementations§

Source§

impl Transaction

Source

pub fn builder(database: &Database) -> TransactionBuilder<'_>

Creates a new TransactionBuilder with the given database.

Source

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

Returns a list of the names of object stores in the transaction’s scope. For an upgrade transaction this is all object stores in the database.

Source

pub fn mode(&self) -> Result<TransactionMode, Error>

Returns the mode the transaction was created with (“readonly” or “readwrite”), or “versionchange” for an upgrade transaction.

Source

pub fn object_store<M>(&self) -> Result<ObjectStore<'_, M>, Error>
where M: Model,

Returns an ObjectStore for a model in transaction’s scope.

Source

pub async fn commit(self) -> Result<TransactionResult, Error>

Attempts to commit the transaction. All pending requests will be allowed to complete, but no new requests will be accepted. This can be used to force a transaction to quickly finish, without waiting for pending requests to fire success events before attempting to commit normally.

Source

pub async fn abort(self) -> Result<TransactionResult, Error>

Aborts the transaction. All pending requests will fail and all changes made to the database will be reverted.

Source

pub async fn done(self) -> Result<TransactionResult, Error>

Waits for the transaction to complete and returns the result.

Trait Implementations§

Source§

impl Debug for Transaction

Source§

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

Formats the value using the given formatter. Read more

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

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.