use crate::api::journal::JournalEnvelope;
#[derive(Debug, Clone)]
pub enum WalOp {
Insert {
tree_id: u64,
key: Vec<u8>,
value: Vec<u8>,
},
Erase {
tree_id: u64,
key: Vec<u8>,
},
RenameObject {
tree_id: u64,
src_key: Vec<u8>,
dst_key: Vec<u8>,
force: bool,
},
Batch {
ops: Vec<WalOp>,
},
DbBatchWithEnvelope {
envelope: JournalEnvelope,
ops: Vec<WalOp>,
},
}
impl WalOp {
#[must_use]
pub const fn tree_id(&self) -> Option<u64> {
match self {
Self::Insert { tree_id, .. }
| Self::Erase { tree_id, .. }
| Self::RenameObject { tree_id, .. } => Some(*tree_id),
Self::Batch { .. } | Self::DbBatchWithEnvelope { .. } => None,
}
}
}