Struct Transaction

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

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

Implementations§

Source§

impl Transaction

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 database(&self) -> Database

Returns the transaction’s connection.

Source

pub fn error(&self) -> Option<DomException>

If the transaction was aborted, returns the error (a DOMException) providing the reason.

Source

pub fn object_store(&self, name: &str) -> Result<ObjectStore, Error>

Returns an ObjectStore in the transaction’s scope.

Source

pub fn commit(self) -> Result<Self, 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 fn abort(self) -> Result<Self, Error>

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

Source

pub fn on_abort<F>(&mut self, callback: F)
where F: FnOnce(Event) + 'static,

Adds an event handler for abort event.

Source

pub fn on_complete<F>(&mut self, callback: F)
where F: FnOnce(Event) + 'static,

Adds an event handler for complete event.

Source

pub fn on_error<F>(&mut self, callback: F)
where F: FnOnce(Event) + 'static,

Adds an event handler for error event.

Source

pub fn forget_callbacks(&mut self)

Release memory management of the callbacks to JS GC.

Note: This may leak memory. Read more about it here.

Trait Implementations§

Source§

impl Debug for Transaction

Source§

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

Formats the value using the given formatter. Read more
Source§

impl From<IdbTransaction> for Transaction

Source§

fn from(inner: IdbTransaction) -> Self

Converts to this type from the input type.
Source§

impl From<Transaction> for IdbTransaction

Source§

fn from(transaction: Transaction) -> Self

Converts to this type from the input type.
Source§

impl From<Transaction> for JsValue

Source§

fn from(value: Transaction) -> Self

Converts to this type from the input type.
Source§

impl IntoFuture for Transaction

Source§

type Output = <<Transaction as IntoFuture>::IntoFuture as Future>::Output

The output that the future will produce on completion.
Source§

type IntoFuture = TransactionFuture

Which kind of future are we turning this into?
Source§

fn into_future(self) -> Self::IntoFuture

Creates a future from a value. Read more
Source§

impl TryFrom<EventTarget> for Transaction

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(target: EventTarget) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<JsValue> for Transaction

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: JsValue) -> Result<Self, Self::Error>

Performs the conversion.

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.