diff --git a/harmony/src/modules/application/feature.rs b/harmony/src/modules/application/feature.rs new file mode 100644 index 0000000..9c12553 --- /dev/null +++ b/harmony/src/modules/application/feature.rs @@ -0,0 +1,41 @@ +use async_trait::async_trait; +use serde::Serialize; + +use crate::topology::Topology; +/// An ApplicationFeature provided by harmony, such as Backups, Monitoring, MultisiteAvailability, +/// ContinuousIntegration, ContinuousDelivery +#[async_trait] +pub trait ApplicationFeature: + std::fmt::Debug + Send + Sync + ApplicationFeatureClone +{ + async fn ensure_installed(&self, topology: &T) -> Result<(), String>; + fn name(&self) -> String; +} + +trait ApplicationFeatureClone { + fn clone_box(&self) -> Box>; +} + +impl ApplicationFeatureClone for A +where + A: ApplicationFeature + Clone + 'static, +{ + fn clone_box(&self) -> Box> { + Box::new(self.clone()) + } +} + +impl Serialize for Box> { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + todo!() + } +} + +impl Clone for Box> { + fn clone(&self) -> Self { + self.clone_box() + } +}