Skip to main content

Transaction

Struct Transaction 

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

A database transaction.

Implementations§

Source§

impl Transaction

Source

pub fn begin() -> Self

Creates a new transaction.

Source

pub fn id(&self) -> TransactionId

Returns the transaction ID.

Source

pub fn state(&self) -> TransactionState

Returns the current state.

Source

pub fn is_active(&self) -> bool

Returns true if the transaction is active.

Source

pub fn insert( &mut self, cache: &mut TableCache, table: &str, row: Row, ) -> Result<RowId>

Inserts a row within this transaction.

Source

pub fn update( &mut self, cache: &mut TableCache, table: &str, row_id: RowId, new_row: Row, ) -> Result<()>

Updates a row within this transaction.

Source

pub fn delete( &mut self, cache: &mut TableCache, table: &str, row_id: RowId, ) -> Result<Row>

Deletes a row within this transaction.

Source

pub fn commit(self) -> Result<Vec<JournalEntry>>

Commits the transaction.

Source

pub fn rollback(self, cache: &mut TableCache) -> Result<()>

Rolls back the transaction.

Source

pub fn get_changes(&self) -> &[JournalEntry]

Returns the journal entries.

Source

pub fn journal(&self) -> &Journal

Returns the journal.

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.