Skip to main content

HookStep

Trait HookStep 

Source
pub trait HookStep: Send {
    // Required methods
    fn event_name(&self) -> &'static str;
    fn to_envelope(&self) -> Value;
    fn apply_verdict(
        &mut self,
        verdict: &Value,
    ) -> Result<HookControl, VerdictError>;
}
Expand description

The step state for a mount point. Consumed by two kinds of hooks:

  • Internal Rust hook: takes &mut Self directly, mutates fields to inject data, and returns a HookControl on its own.
  • User-configured hook: Self::to_envelope produces JSON fed to stdin/templates; the handler outputs JSON, which Self::apply_verdict applies back to the step (mutating data) and parses into a HookControl.

Required Methods§

Source

fn event_name(&self) -> &'static str

Event name (snake_case). Used in envelope headers and matchers.

Source

fn to_envelope(&self) -> Value

Projects the step into an input envelope — fed to command stdin / prompt templates. Contains a common header plus step-specific fields.

Source

fn apply_verdict( &mut self, verdict: &Value, ) -> Result<HookControl, VerdictError>

Apply the handler’s output verdict (JSON) back to this step: parse the common control / additional_context fields, then handle the step-specific “fill output” fields. Returns a control directive.

§Errors

Returns VerdictError if the verdict’s control is an unknown value or the step-specific fields are malformed.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§