pub trait TransactionStore: Send + Sync {
// Required methods
fn create(
&self,
record: TransactionRecord,
) -> Result<(), TransactionStoreError>;
fn get(
&self,
id: TransactionId,
) -> Result<TransactionRecord, TransactionStoreError>;
fn compare_and_transition(
&self,
id: TransactionId,
expected: TransactionState,
next: TransactionState,
) -> Result<TransactionRecord, TransactionStoreError>;
fn approve(
&self,
id: TransactionId,
grant: ApprovalGrant,
) -> Result<TransactionRecord, TransactionStoreError>;
fn reserve(
&self,
id: TransactionId,
now_unix_ms: u64,
) -> Result<CommitReservation, TransactionStoreError>;
}Expand description
Atomic transaction-state operations required by the runtime and committer.
Required Methods§
Sourcefn create(&self, record: TransactionRecord) -> Result<(), TransactionStoreError>
fn create(&self, record: TransactionRecord) -> Result<(), TransactionStoreError>
Insert one record whose state was reached through validated in-memory edges.
§Errors
Returns TransactionStoreError::Duplicate when the ID already exists.
Sourcefn get(
&self,
id: TransactionId,
) -> Result<TransactionRecord, TransactionStoreError>
fn get( &self, id: TransactionId, ) -> Result<TransactionRecord, TransactionStoreError>
Load one immutable record snapshot.
§Errors
Returns TransactionStoreError::NotFound for an unknown ID.
Sourcefn compare_and_transition(
&self,
id: TransactionId,
expected: TransactionState,
next: TransactionState,
) -> Result<TransactionRecord, TransactionStoreError>
fn compare_and_transition( &self, id: TransactionId, expected: TransactionState, next: TransactionState, ) -> Result<TransactionRecord, TransactionStoreError>
Compare exact state and perform one valid transition atomically.
§Errors
Returns a state conflict or transition error without modifying the record.
Sourcefn approve(
&self,
id: TransactionId,
grant: ApprovalGrant,
) -> Result<TransactionRecord, TransactionStoreError>
fn approve( &self, id: TransactionId, grant: ApprovalGrant, ) -> Result<TransactionRecord, TransactionStoreError>
Bind an independent grant and move a pending state to Approved atomically.
§Errors
Returns an error for an ID mismatch, missing record, or wrong current state.
Sourcefn reserve(
&self,
id: TransactionId,
now_unix_ms: u64,
) -> Result<CommitReservation, TransactionStoreError>
fn reserve( &self, id: TransactionId, now_unix_ms: u64, ) -> Result<CommitReservation, TransactionStoreError>
Atomically consume AutoApproved or unexpired Approved into Reserved.
§Errors
Returns a state conflict, missing-approval error, or expiry error. An expired
record is atomically moved to Expired.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".