commonware_storage/adb/operation/fixed/mod.rs
1use crate::mmr::Location;
2use commonware_codec::{CodecFixed, FixedSize, Read, Write};
3use commonware_utils::Array;
4
5pub mod ordered;
6pub mod unordered;
7
8/// Methods common to fixed-size operation types.
9pub trait FixedOperation: Read<Cfg = ()> + Write + FixedSize + Sized {
10 /// The key type for this operation.
11 type Key: Array;
12
13 /// The value type for this operation.
14 type Value: CodecFixed;
15
16 /// Returns the commit floor location if this operation is a commit operation with a floor
17 /// value, None otherwise.
18 fn commit_floor(&self) -> Option<Location>;
19
20 /// Returns the key if this operation involves a key, None otherwise.
21 fn key(&self) -> Option<&Self::Key>;
22
23 /// Returns the value if this operation involves a value, None otherwise.
24 fn value(&self) -> Option<&Self::Value>;
25
26 /// Consumes the operation and returns the value if this operation involves a value, None otherwise.
27 fn into_value(self) -> Option<Self::Value>;
28}