reifydb_core/interface/transaction/
cdc.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::ops::Bound;
5
6use reifydb_type::Result;
7
8use crate::{CommitVersion, interface::Cdc};
9
10pub trait CdcTransaction: Send + Sync + Clone + 'static {
11	type Query<'a>: CdcQueryTransaction;
12
13	fn begin_query(&self) -> Result<Self::Query<'_>>;
14
15	fn with_query<F, R>(&self, f: F) -> Result<R>
16	where
17		F: FnOnce(&mut Self::Query<'_>) -> Result<R>,
18	{
19		let mut tx = self.begin_query()?;
20		f(&mut tx)
21	}
22}
23
24pub trait CdcQueryTransaction: Send + Sync + Clone + 'static {
25	fn get(&self, version: CommitVersion) -> Result<Option<Cdc>>;
26
27	fn range(
28		&self,
29		start: Bound<CommitVersion>,
30		end: Bound<CommitVersion>,
31	) -> Result<Box<dyn Iterator<Item = Cdc> + '_>>;
32
33	fn scan(&self) -> Result<Box<dyn Iterator<Item = Cdc> + '_>>;
34
35	fn count(&self, version: CommitVersion) -> Result<usize>;
36}