Struct idb_sys::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<(), 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<(), 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.

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 TryFrom<EventTarget> for Transaction

§

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

§

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

§

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

§

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.