1use arrow::record_batch::RecordBatch;
8
9#[cfg(feature = "cdc")]
10pub mod cdc;
11#[cfg(feature = "mq")]
12pub mod mq;
13
14#[derive(Debug, Clone, PartialEq, Eq)]
16pub struct BatchEnvelope<P> {
17 source_position: P,
18 schema_revision: u64,
19}
20
21impl<P> BatchEnvelope<P> {
22 #[must_use]
24 pub const fn new(source_position: P, schema_revision: u64) -> Self {
25 Self {
26 source_position,
27 schema_revision,
28 }
29 }
30
31 #[must_use]
33 pub const fn source_position(&self) -> &P {
34 &self.source_position
35 }
36
37 #[must_use]
39 pub const fn schema_revision(&self) -> u64 {
40 self.schema_revision
41 }
42
43 #[must_use]
45 pub fn into_source_position(self) -> P {
46 self.source_position
47 }
48}
49
50#[derive(Debug, Clone, PartialEq)]
52pub struct EnvelopedBatch<T, P> {
53 batch: T,
54 envelope: BatchEnvelope<P>,
55}
56
57impl<T, P> EnvelopedBatch<T, P> {
58 #[must_use]
60 pub const fn new(batch: T, envelope: BatchEnvelope<P>) -> Self {
61 Self { batch, envelope }
62 }
63
64 #[must_use]
66 pub const fn batch(&self) -> &T {
67 &self.batch
68 }
69
70 #[must_use]
72 pub const fn envelope(&self) -> &BatchEnvelope<P> {
73 &self.envelope
74 }
75
76 #[must_use]
78 pub fn into_batch(self) -> T {
79 self.batch
80 }
81
82 #[must_use]
84 pub fn into_parts(self) -> (T, BatchEnvelope<P>) {
85 (self.batch, self.envelope)
86 }
87}
88
89pub type EnvelopedRecordBatch<P> = EnvelopedBatch<RecordBatch, P>;