Rust · Transactions

Transactions

use ustore::CommitStamp;use ustore::Isolation;use ustore::ReadStamp;use ustore::Transaction;use ustore::Watch;use ustore::db::Stage;use ustore::db::Commit;use ustore::db::Rollback;use ustore::db::Reset; 1.0.0-rc.1 · d6d40961

API

StructCommitStampThe position of a commit in commit order, visible to every snapshot whose read stamp is at or above it.
db.rs:1123 ↗
pub struct CommitStamp(pub u64);

Fields

0u64

Implements

Clone, Copy, StructuralPartialEq, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Default, From<CommitStamp>
EnumIsolationThe isolation the in-memory engine delivers to the transactions of a database.
db.rs:1912 ↗
pub enum Isolation

Values

StrictSerializable0Reads and writes both take part in one serial order.
Snapshot1A transaction reads the snapshot it began at and conflicts only on what it wrote.

Implements

Clone, Copy, StructuralPartialEq, PartialEq, Eq, Debug, Default, Hash, Display, FromStr
StructReadStampThe stamp a transaction or a snapshot reads at, which a stage reports and the commit after it validates against.
db.rs:1118 ↗
pub struct ReadStamp(pub u64);

Fields

0u64

Implements

Clone, Copy, StructuralPartialEq, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Default
StructTransactionAn optimistic transaction grouping reads and writes across collections and modalities.8
db.rs:4028 ↗
pub struct Transaction<'db>

It serves one call at a time, so a call on a transaction that serves an unfinished deferred one finishes with Status::Contended. It is freed before its database closes, which the borrow of the database carries, and dropping it waits for every deferred call naming it to finish.

Implements

Debug, Drop, Send
collectionThe collection name addresses inside this transaction, which watches what it touches.
db.rs:97 ↗
pub fn collection(&self, name: &str) -> Result<Collection<'_, Transaction<'db>>>

The name resolves at the head, where a first write creates a missing collection at once, since collections are created nowhere else. The collection borrows the transaction, so no call goes through it after Transaction::commit.

viewThe view every call inside this transaction addresses, watching the keys it touches or not.
db.rs:4035 ↗
pub fn view(&self, watch: Watch) -> On<'_, Transaction<'db>>
onThe view of this transaction watching the keys it touches, with every call through it running on executor.
db.rs:4049 ↗
pub fn on<'with>(&'with self, executor: &'with Executor) -> On<'with, Transaction<'db>>
deferredThe view of this transaction watching the keys it touches, with every verb deferred on executor.
db.rs:4054 ↗
pub fn deferred<'with>(
    &'with self,
    executor: &'with Executor,
) -> DeferredOn<'with, Transaction<'db>>
stageStages the writes as the first phase of a two-phase commit, reporting the stamp the transaction reads at.
db.rs:4059 ↗
pub fn stage(&mut self) -> Result<ReadStamp>
commitCommits the writes, reporting the commit's position in commit order.
db.rs:4067 ↗
pub fn commit(&mut self, durability: Durability) -> Result<CommitStamp>

A conflict is reported rather than retried, and the transaction keeps its contents either way, so a caller may stage them again after Transaction::rollback or start over after Transaction::reset.

rollbackWithdraws a stage, releasing whatever it claimed, while keeping the reads and writes to stage again.
db.rs:4072 ↗
pub fn rollback(&mut self) -> Result<()>
resetDiscards the reads and writes and reopens the transaction on the newest state, ready for another try.
db.rs:4077 ↗
pub fn reset(&mut self) -> Result<()>
EnumWatchWhether the calls of a transaction watch the keys they touch for conflicts, as ustore_watch_t spells it.
db.rs:1263 ↗
pub enum Watch

Only a transaction watches anything, so the head of a database and a snapshot never carry this, and it changes what a call does only at [Isolation::Snapshot]: a strictly serializable transaction puts every read it makes into the one serial order whatever this says.

Values

Keys0Every key the view reads or writes is recorded, so a concurrent writer conflicts at the commit.
None1Nothing the view touches is watched, so a snapshot-isolated transaction commits over a concurrent writer instead of conflicting with it.

Implements

Clone, Copy, StructuralPartialEq, PartialEq, Eq, Debug, Default, Hash, Display, FromStr
StructStageThe first phase of a two-phase commit; see On::stage.
db.rs:4131 ↗
pub struct Stage

Implements

Debug
StructCommitA commit of a transaction; see On::commit.
db.rs:4166 ↗
pub struct Commit

Implements

Debug
StructRollbackA withdrawal of a stage; see On::rollback.
db.rs:4203 ↗
pub struct Rollback;

Implements

Debug
StructResetA reset of a transaction for another try; see On::reset.
db.rs:4235 ↗
pub struct Reset

Implements

Debug