Crates.io | tc-transact |
lib.rs | tc-transact |
version | 0.21.1 |
source | src |
created_at | 2021-02-21 01:46:48.143321 |
updated_at | 2024-08-15 20:08:22.787159 |
description | Traits and locking utilities for a TinyChain transaction. |
homepage | |
repository | https://github.com/haydnv/tinychain.git |
max_upload_size | |
id | 358299 |
size | 82,157 |
This crate is used internally by TinyChain. It provides traits and data structures to support transactional mutations of in-memory and persistent datatypes.
Example:
use tc_transact::{TxnId, TxnLock};
let version = TxnLock::new("version", 0);
let txn_one = TxnId::new(1);
let txn_two = TxnId::new(2);
let txn_three = TxnId::new(3);
assert_eq!(version.read(txn_one).await.unwrap(), 0);
*(version.write(txn_two).await.unwrap()) = 2;
version.commit(txn_two).await;
assert_eq!(version.read(txn_three).await.unwrap(), 2);
For more information on TinyChain, see http://github.com/haydnv/tinychain