Skip to main content

Transaction

Struct Transaction 

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

A serializable snapshot isolated database transaction.

All mutations are buffered in-memory. On commit() they are flushed to IndexedDB in a single synchronous batch so that the IDB transaction never goes idle between requests.

Implementations§

Source§

impl Transaction

Source

pub fn closed(&self) -> bool

Source

pub async fn cancel(&mut self) -> Result<(), Error>

Source

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

Commit: flush all buffered writes to IndexedDB in one atomic batch.

Opens a fresh read-write IDB transaction. Puts are batched via put_all (all IDB requests fired synchronously, only the last awaited). Deletes are issued sequentially – each await is safe because the next delete() call is queued in the same microtask as the previous request’s completion, keeping the transaction alive.

Source

pub async fn exists(&self, key: Key) -> Result<bool, Error>

Source

pub async fn get(&self, key: Key) -> Result<Option<Val>, Error>

Source

pub async fn set(&mut self, key: Key, val: Val) -> Result<(), Error>

Source

pub async fn put(&mut self, key: Key, val: Val) -> Result<(), Error>

Source

pub async fn putc( &mut self, key: Key, val: Val, chk: Option<Val>, ) -> Result<(), Error>

Source

pub async fn del(&mut self, key: Key) -> Result<(), Error>

Source

pub async fn delc(&mut self, key: Key, chk: Option<Val>) -> Result<(), Error>

Source

pub async fn keys(&self, rng: Range<Key>, limit: u32) -> Result<Vec<Key>, Error>

Source

pub async fn keysr( &self, rng: Range<Key>, limit: u32, ) -> Result<Vec<Key>, Error>

Source

pub async fn scan( &self, rng: Range<Key>, limit: u32, ) -> Result<Vec<(Key, Val)>, Error>

Source

pub async fn scanr( &self, rng: Range<Key>, limit: u32, ) -> Result<Vec<(Key, Val)>, Error>

Source

pub async fn set_savepoint(&mut self) -> Result<(), Error>

Source

pub async fn rollback_to_savepoint(&mut self) -> Result<(), Error>

Rollback to the most recent savepoint by replaying undo operations against the in-memory buffer. No IDB calls needed.

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.