use crate::ctx::Ctx;
use crate::error::CordisError;
use crate::key::TypeKey;
use crate::{BoxFuture, Effect};
pub trait Plugin: Send + Sync + 'static {
fn name(&self) -> &str;
fn injects(&self) -> &[TypeKey] {
&[]
}
fn validate(&self) -> Result<(), CordisError> {
Ok(())
}
fn apply<'a>(&'a self, ctx: &'a Ctx) -> BoxFuture<'a, Result<Effect, CordisError>>;
}
pub trait PluginFactory<C: Send + Sync + 'static>: Send + Sync + 'static {
fn name(&self) -> &str {
std::any::type_name::<Self>()
}
fn injects(&self) -> &[TypeKey] {
&[]
}
fn validate_config(&self, _config: &C) -> Result<(), CordisError> {
Ok(())
}
fn build(&self, config: &C) -> Result<Box<dyn Plugin>, CordisError>;
}