ActionStrategy

Trait ActionStrategy 

Source
pub trait ActionStrategy: Send + Sync {
    // Required methods
    fn can_handle(&self, key: &str) -> bool;
    fn validate(
        &self,
        key: &str,
        _value: &Value,
        config: &EspforgeConfiguration,
        manifests: &HashMap<String, ComponentManifest>,
    ) -> ValidationResult;
    fn render(
        &self,
        key: &str,
        value: &Value,
        config: &EspforgeConfiguration,
        manifests: &HashMap<String, ComponentManifest>,
        tera: &mut Tera,
    ) -> Result<String>;
}
Expand description

Trait Definition (Design Pattern: Strategy)

Required Methods§

Source

fn can_handle(&self, key: &str) -> bool

Returns true if this strategy claims responsibility for this action key.

Source

fn validate( &self, key: &str, _value: &Value, config: &EspforgeConfiguration, manifests: &HashMap<String, ComponentManifest>, ) -> ValidationResult

Validates the action logic (e.g. does the component exist? does the method exist?). This is used by the AppNibbler.

Source

fn render( &self, key: &str, value: &Value, config: &EspforgeConfiguration, manifests: &HashMap<String, ComponentManifest>, tera: &mut Tera, ) -> Result<String>

Renders the actual code for the action. This is used by the ContextResolver.

Implementors§