commonware_storage/qmdb/operation.rs
1use crate::mmr::Location;
2use commonware_utils::Array;
3
4/// An operation that can be applied to a database.
5pub trait Operation {
6 /// The key type for this operation.
7 type Key: Array;
8
9 /// Returns the key if this operation involves a key, None otherwise.
10 fn key(&self) -> Option<&Self::Key>;
11
12 /// If this operation updates its key's value.
13 fn is_update(&self) -> bool;
14
15 /// If this operation deletes its key's value.
16 fn is_delete(&self) -> bool;
17
18 /// The inactivity floor location if this operation is a commit operation with a floor value,
19 /// None otherwise.
20 fn has_floor(&self) -> Option<Location>;
21}
22
23/// A trait for operations used by database variants that support commit operations.
24pub trait Committable {
25 /// If this operation is a commit operation.
26 fn is_commit(&self) -> bool;
27}