lance_table/format/
transaction.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright The Lance Authors
3
4//! Transaction struct for lance-table format layer.
5//!
6//! This struct is introduced to provide a Struct-first API for passing transaction
7//! information within the lance-table crate. It mirrors the protobuf Transaction
8//! message at a semantic level while remaining crate-local, so lance-table does
9//! not depend on higher layers (e.g., lance crate).
10//!
11//! Conversion to protobuf occurs at the write boundary. See the From<Transaction>
12//! implementation below.
13
14use crate::format::pb;
15
16#[derive(Clone, Debug, PartialEq)]
17pub struct Transaction {
18    /// Crate-local representation backing: protobuf Transaction.
19    /// Keeping this simple avoids ring dependencies while still enabling
20    /// Struct-first parameter passing in lance-table.
21    pub inner: pb::Transaction,
22}
23
24impl Transaction {
25    /// Accessor for testing or internal inspection if needed.
26    pub fn as_pb(&self) -> &pb::Transaction {
27        &self.inner
28    }
29}
30
31/// Write-boundary conversion: serialize using protobuf at the last step.
32impl From<Transaction> for pb::Transaction {
33    fn from(tx: Transaction) -> Self {
34        tx.inner
35    }
36}
37
38impl From<pb::Transaction> for Transaction {
39    fn from(pb_tx: pb::Transaction) -> Self {
40        Self { inner: pb_tx }
41    }
42}