//! The operation type a compact db is built over. use crate::{ merkle::{Family, Location}, qmdb::operation::Committable, }; use commonware_codec::CodecShared; pub(in crate::qmdb) mod sealed { /// The parts of [`super::Operation`] only the compact db uses. pub trait Sealed { /// The mutations a batch accumulates before merkleization. Their iteration order is the /// order their operations are appended. type Mutations: Default + Send + IntoIterator; /// The name recorded on tracing spans. const NAME: &'static str; /// Build the operation for one of a batch's mutations. fn mutation(mutation: ::Item) -> Self; } } /// The operation type a compact db is built over. /// /// Sealed: implemented by [`crate::qmdb::keyless::Operation`] and /// [`crate::qmdb::immutable::Operation`]. pub trait Operation: sealed::Sealed + Committable + CodecShared + Clone + 'static { /// The commit metadata type. type Metadata: Clone + Send; /// Build a commit operation. fn commit(metadata: Option, inactivity_floor_loc: Location) -> Self; /// The metadata carried by a commit operation; `None` for a commit without metadata or any /// other operation. fn metadata(&self) -> Option<&Self::Metadata>; }