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: MetadataReservationThe reservation for the metadata for this transaction.
Implementations§
Source§impl<'a> Transaction<'a>
impl<'a> Transaction<'a>
Sourcepub async fn new(
fs: Arc<FxFilesystem>,
options: Options<'a>,
txn_locks: LockKeys,
) -> Result<Transaction<'a>, Error>
pub async fn new( fs: Arc<FxFilesystem>, 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.
pub fn mutations(&self) -> &BTreeSet<TxnMutation<'a>>
pub fn take_mutations(&mut self) -> BTreeSet<TxnMutation<'a>>
Sourcepub fn add(&mut self, object_id: u64, mutation: Mutation) -> Option<Mutation>
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.
Sourcepub fn remove(&mut self, object_id: u64, mutation: Mutation)
pub fn remove(&mut self, object_id: u64, mutation: Mutation)
Removes a mutation that matches mutation.
Sourcepub fn add_with_object(
&mut self,
object_id: u64,
mutation: Mutation,
associated_object: AssocObj<'a>,
) -> Option<Mutation>
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.
pub fn add_checksum( &mut self, range: Range<u64>, checksums: Vec<Checksum>, first_write: bool, )
pub fn includes_write(&self) -> bool
pub fn checksums(&self) -> &[(Range<u64>, Vec<Checksum>, bool)]
pub fn take_checksums(&mut self) -> Vec<(Range<u64>, Vec<Checksum>, bool)>
Sourcepub fn get_object_mutation(
&self,
store_object_id: u64,
key: ObjectKey,
) -> Option<&ObjectStoreMutation>
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.
Sourcepub async fn commit(self) -> Result<u64, Error>
pub async fn commit(self) -> Result<u64, Error>
Commits a transaction. If successful, returns the journal offset of the transaction.
Sourcepub async fn commit_with_callback<R: Send>(
self,
f: impl FnOnce(u64) -> R + Send,
) -> Result<R, Error>
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.
Sourcepub async fn commit_and_continue(&mut self) -> Result<(), Error>
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).
Sourcepub async fn commit_prepare(&self)
pub async fn commit_prepare(&self)
Prepares to commit by upgrading transaction locks to write locks and waiting for active readers to finish.
Trait Implementations§
Source§impl Debug for Transaction<'_>
impl Debug for Transaction<'_>
Source§impl Drop for Transaction<'_>
impl Drop for Transaction<'_>
Auto Trait Implementations§
impl<'a> !Freeze for Transaction<'a>
impl<'a> !RefUnwindSafe for Transaction<'a>
impl<'a> !Unpin for Transaction<'a>
impl<'a> !UnwindSafe for Transaction<'a>
impl<'a> Send for Transaction<'a>
impl<'a> Sync for Transaction<'a>
impl<'a> UnsafeUnpin for Transaction<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
§impl<F, N> FidlIntoNative<Box<N>> for Fwhere
F: FidlIntoNative<N>,
impl<F, N> FidlIntoNative<Box<N>> for Fwhere
F: FidlIntoNative<N>,
fn fidl_into_native(self) -> Box<N>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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