1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use async_trait::async_trait;
use destream::en;
use tc_error::*;
use tcgeneric::Id;
mod id;
pub mod fs;
pub mod lock;
pub use id::TxnId;
#[async_trait]
pub trait IntoView<'en, D: fs::Dir> {
type Txn: Transaction<D>;
type View: en::IntoStream<'en> + Sized;
async fn into_view(self, txn: Self::Txn) -> TCResult<Self::View>;
}
#[async_trait]
pub trait Transact {
async fn commit(&self, txn_id: &TxnId);
async fn finalize(&self, txn_id: &TxnId);
}
#[async_trait]
pub trait Transaction<D: fs::Dir>: Clone + Sized + Send + Sync + 'static {
fn id(&'_ self) -> &'_ TxnId;
fn context(&'_ self) -> &'_ D;
fn into_context(self) -> D;
async fn subcontext(&self, id: Id) -> TCResult<Self>;
async fn subcontext_tmp(&self) -> TCResult<Self>;
}