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
sourceimpl Transaction
impl Transaction
sourcepub fn store_names(&self) -> Vec<String>
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.
sourcepub fn mode(&self) -> Result<TransactionMode, Error>
pub fn mode(&self) -> Result<TransactionMode, Error>
Returns the mode the transaction was created with (“readonly” or “readwrite”), or “versionchange” for an upgrade transaction.
sourcepub fn error(&self) -> Option<DomException>
pub fn error(&self) -> Option<DomException>
If the transaction was aborted, returns the error (a DOMException) providing the reason.
sourcepub fn object_store(&self, name: &str) -> Result<ObjectStore, Error>
pub fn object_store(&self, name: &str) -> Result<ObjectStore, Error>
Returns an ObjectStore in the transaction’s scope.
sourcepub fn commit(&self) -> Result<(), Error>
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.
sourcepub fn abort(&self) -> Result<(), Error>
pub fn abort(&self) -> Result<(), Error>
Aborts the transaction. All pending requests will fail and all changes made to the database will be reverted.
sourcepub fn on_abort<F>(&mut self, callback: F) where
F: FnOnce(Event) + 'static,
pub fn on_abort<F>(&mut self, callback: F) where
F: FnOnce(Event) + 'static,
Adds an event handler for abort event.
sourcepub fn on_complete<F>(&mut self, callback: F) where
F: FnOnce(Event) + 'static,
pub fn on_complete<F>(&mut self, callback: F) where
F: FnOnce(Event) + 'static,
Adds an event handler for complete event.
Trait Implementations
sourceimpl Debug for Transaction
impl Debug for Transaction
sourceimpl From<IdbTransaction> for Transaction
impl From<IdbTransaction> for Transaction
sourcefn from(inner: IdbTransaction) -> Self
fn from(inner: IdbTransaction) -> Self
Converts to this type from the input type.
sourceimpl From<Transaction> for IdbTransaction
impl From<Transaction> for IdbTransaction
sourcefn from(transaction: Transaction) -> Self
fn from(transaction: Transaction) -> Self
Converts to this type from the input type.
sourceimpl From<Transaction> for JsValue
impl From<Transaction> for JsValue
sourcefn from(value: Transaction) -> Self
fn from(value: Transaction) -> Self
Converts to this type from the input type.
sourceimpl TryFrom<EventTarget> for Transaction
impl TryFrom<EventTarget> for Transaction
Auto Trait Implementations
impl !RefUnwindSafe for Transaction
impl !Send for Transaction
impl !Sync for Transaction
impl Unpin for Transaction
impl !UnwindSafe for Transaction
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more