#[cfg(doc)]
use super::Transaction;
use crate::engine_data::FilteredEngineData;
use crate::EngineData;
#[allow(private_bounds)] pub trait ExecutionMode: sealed::Sealed + StagedDataChanges + Default + std::fmt::Debug {}
pub(crate) trait StagedDataChanges {
fn has_adds(&self) -> bool;
fn has_removes(&self) -> bool;
fn has_dv_inputs(&self) -> bool;
fn has_dv_updates(&self) -> bool;
}
#[derive(Default)]
pub struct Imperative {
pub(super) add_files_metadata: Vec<Box<dyn EngineData>>,
pub(super) remove_files_metadata: Vec<FilteredEngineData>,
pub(super) dv_matched_files: Vec<FilteredEngineData>,
pub(super) num_dv_updates: usize,
}
impl ExecutionMode for Imperative {}
impl StagedDataChanges for Imperative {
fn has_adds(&self) -> bool {
!self.add_files_metadata.is_empty()
}
fn has_removes(&self) -> bool {
!self.remove_files_metadata.is_empty()
}
fn has_dv_inputs(&self) -> bool {
!self.dv_matched_files.is_empty()
}
fn has_dv_updates(&self) -> bool {
self.num_dv_updates > 0
}
}
impl std::fmt::Debug for Imperative {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Imperative")
.field("add_batches", &self.add_files_metadata.len())
.field("remove_batches", &self.remove_files_metadata.len())
.field("dv_batches", &self.dv_matched_files.len())
.field("num_dv_updates", &self.num_dv_updates)
.finish()
}
}
mod sealed {
use super::Imperative;
pub trait Sealed {}
impl Sealed for Imperative {}
}