Struct Transaction

Source
pub struct Transaction<'a> {
    pub allocator_reservation: Option<&'a Reservation>,
    pub metadata_reservation: MetadataReservation,
    /* private fields */
}
Expand description

A transaction groups mutation records to be committed as a group.

Fields§

§allocator_reservation: Option<&'a Reservation>

If set, an allocator reservation that should be used for allocations.

§metadata_reservation: MetadataReservation

The reservation for the metadata for this transaction.

Implementations§

Source§

impl<'a> Transaction<'a>

Source

pub async fn new( txn_guard: TxnGuard<'a>, options: Options<'a>, txn_locks: LockKeys, ) -> Result<Transaction<'a>, Error>

Creates a new transaction. txn_locks are read locks that can be upgraded to write locks at commit time.

Source

pub fn txn_guard(&self) -> &TxnGuard<'_>

Source

pub fn mutations(&self) -> &BTreeSet<TxnMutation<'a>>

Source

pub fn take_mutations(&mut self) -> BTreeSet<TxnMutation<'a>>

Source

pub fn add(&mut self, object_id: u64, mutation: Mutation) -> Option<Mutation>

Adds a mutation to this transaction. If the mutation already exists, it is replaced and the old mutation is returned.

Source

pub fn remove(&mut self, object_id: u64, mutation: Mutation)

Removes a mutation that matches mutation.

Source

pub fn add_with_object( &mut self, object_id: u64, mutation: Mutation, associated_object: AssocObj<'a>, ) -> Option<Mutation>

Adds a mutation with an associated object. If the mutation already exists, it is replaced and the old mutation is returned.

Source

pub fn add_checksum( &mut self, range: Range<u64>, checksums: Vec<Checksum>, first_write: bool, )

Source

pub fn checksums(&self) -> &[(Range<u64>, Vec<Checksum>, bool)]

Source

pub fn take_checksums(&mut self) -> Vec<(Range<u64>, Vec<Checksum>, bool)>

Source

pub fn is_empty(&self) -> bool

Returns true if this transaction has no mutations.

Source

pub fn get_object_mutation( &self, store_object_id: u64, key: ObjectKey, ) -> Option<&ObjectStoreMutation>

Searches for an existing object mutation within the transaction that has the given key and returns it if found.

Source

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

Commits a transaction. If successful, returns the journal offset of the transaction.

Source

pub async fn commit_with_callback<R: Send>( self, f: impl FnOnce(u64) -> R + Send, ) -> Result<R, Error>

Commits and then runs the callback whilst locks are held. The callback accepts a single parameter which is the journal offset of the transaction.

Source

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

Commits the transaction, but allows the transaction to be used again. The locks are not dropped (but transaction locks will get downgraded to read locks).

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 Drop for Transaction<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a> !Freeze for Transaction<'a>

§

impl<'a> !RefUnwindSafe for Transaction<'a>

§

impl<'a> Send for Transaction<'a>

§

impl<'a> Sync for Transaction<'a>

§

impl<'a> !Unpin for Transaction<'a>

§

impl<'a> !UnwindSafe for Transaction<'a>

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, D> Encode<Ambiguous1, D> for T
where D: ResourceDialect,

Source§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
Source§

impl<T, D> Encode<Ambiguous2, D> for T
where D: ResourceDialect,

Source§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V