reifydb_core/interceptor/
transaction.rs

1// Copyright (c) reifydb.com 2025
2// This file is licensed under the AGPL-3.0-or-later, see license.md file
3
4use std::marker::PhantomData;
5
6use crate::{
7	CommitVersion, define_api_function, define_closure_interceptor, define_interceptor, interface::TransactionId,
8};
9
10// PRE COMMIT
11define_interceptor!(
12	context: PreCommitContext<T>,
13	trait: PreCommitInterceptor,
14	fields: {
15		txn: &'a mut T}
16);
17
18define_closure_interceptor!(ClosurePreCommitInterceptor, PreCommitInterceptor, PreCommitContext, with_transaction);
19
20define_api_function!(
21	pre_commit,
22	ClosurePreCommitInterceptor<T, F>,
23	PreCommitContext<T>
24);
25
26// POST COMMIT
27define_interceptor!(
28	context: PostCommitContext,
29	trait: PostCommitInterceptor<T>,
30	fields: {
31		id: TransactionId,
32		version: CommitVersion,
33		changes: TransactionalDefChanges}
34);
35
36define_closure_interceptor!(
37	ClosurePostCommitInterceptor,
38	PostCommitInterceptor,
39	PostCommitContext,
40	no_transaction_param
41);
42
43define_api_function!(post_commit, ClosurePostCommitInterceptor<F>, PostCommitContext);
44
45use crate::{impl_register_interceptor, interface::TransactionalDefChanges};
46
47impl_register_interceptor!(
48	ClosurePreCommitInterceptor<T, F>,
49	PreCommitContext<T>,
50	PreCommitInterceptor,
51	pre_commit
52);
53
54impl_register_interceptor!(ClosurePostCommitInterceptor<F>, PostCommitContext, PostCommitInterceptor<T>, post_commit);