use peace_cfg::ApplyCheck;
use peace_resource_rt::type_reg::untagged::{BoxDtDisplay, DataType};
pub trait ItemApplyRt: DataType {
fn state_current_stored(&self) -> Option<BoxDtDisplay>;
fn state_current(&self) -> BoxDtDisplay;
fn state_target(&self) -> BoxDtDisplay;
fn state_diff(&self) -> BoxDtDisplay;
fn apply_check(&self) -> ApplyCheck;
fn state_applied(&self) -> Option<BoxDtDisplay>;
fn as_data_type(&self) -> &dyn DataType;
fn as_data_type_mut(&mut self) -> &mut dyn DataType;
}
dyn_clone::clone_trait_object!(ItemApplyRt);
impl ItemApplyRt for Box<dyn ItemApplyRt> {
fn state_current_stored(&self) -> Option<BoxDtDisplay> {
self.as_ref().state_current_stored()
}
fn state_current(&self) -> BoxDtDisplay {
self.as_ref().state_current()
}
fn state_target(&self) -> BoxDtDisplay {
self.as_ref().state_target()
}
fn state_diff(&self) -> BoxDtDisplay {
self.as_ref().state_diff()
}
fn apply_check(&self) -> ApplyCheck {
self.as_ref().apply_check()
}
fn state_applied(&self) -> Option<BoxDtDisplay> {
self.as_ref().state_applied()
}
fn as_data_type(&self) -> &dyn DataType {
self.as_ref().as_data_type()
}
fn as_data_type_mut(&mut self) -> &mut dyn DataType {
self.as_mut().as_data_type_mut()
}
}
impl serde::Serialize for dyn ItemApplyRt + '_ {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
erased_serde::serialize(self, serializer)
}
}