deltalake_core/kernel/models/
mod.rs1use std::collections::HashMap;
7
8use serde::{Deserialize, Serialize};
9
10pub(crate) mod actions;
11pub(crate) mod fields;
12
13pub use actions::*;
14
15#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)]
16#[serde(rename_all = "camelCase")]
17#[allow(missing_docs)]
18pub enum Action {
19 #[serde(rename = "metaData")]
20 Metadata(Metadata),
21 Protocol(Protocol),
22 Add(Add),
23 Remove(Remove),
24 Cdc(AddCDCFile),
25 Txn(Transaction),
26 CommitInfo(CommitInfo),
27 DomainMetadata(DomainMetadata),
28}
29
30impl Action {
31 pub fn commit_info(info: HashMap<String, serde_json::Value>) -> Self {
33 Self::CommitInfo(CommitInfo {
34 info,
35 ..Default::default()
36 })
37 }
38}
39
40impl From<Add> for Action {
41 fn from(a: Add) -> Self {
42 Self::Add(a)
43 }
44}
45
46impl From<Remove> for Action {
47 fn from(a: Remove) -> Self {
48 Self::Remove(a)
49 }
50}
51
52impl From<AddCDCFile> for Action {
53 fn from(a: AddCDCFile) -> Self {
54 Self::Cdc(a)
55 }
56}
57
58impl From<Metadata> for Action {
59 fn from(a: Metadata) -> Self {
60 Self::Metadata(a)
61 }
62}
63
64impl From<Protocol> for Action {
65 fn from(a: Protocol) -> Self {
66 Self::Protocol(a)
67 }
68}
69
70impl From<Transaction> for Action {
71 fn from(a: Transaction) -> Self {
72 Self::Txn(a)
73 }
74}
75
76impl From<CommitInfo> for Action {
77 fn from(a: CommitInfo) -> Self {
78 Self::CommitInfo(a)
79 }
80}
81
82impl From<DomainMetadata> for Action {
83 fn from(a: DomainMetadata) -> Self {
84 Self::DomainMetadata(a)
85 }
86}