Skip to main content

CallInterceptor

Trait CallInterceptor 

Source
pub trait CallInterceptor: Send + Sync {
    // Required methods
    fn before_import(
        &self,
        interface: &str,
        function: &str,
        input: &Value,
    ) -> Option<Value>;
    fn after_import(
        &self,
        interface: &str,
        function: &str,
        input: &Value,
        output: &Value,
    );
    fn before_export(&self, function: &str, input: &Value) -> Option<Value>;
    fn after_export(&self, function: &str, input: &Value, output: &Value);
}
Expand description

Trait for intercepting calls at the Pack runtime level.

Implementations can record calls (for audit/replay) or short-circuit them with previously recorded values (for replay).

All methods are synchronous since recording (push to list) and replay (read from list) are simple lookups that don’t need async.

Required Methods§

Source

fn before_import( &self, interface: &str, function: &str, input: &Value, ) -> Option<Value>

Called before a host function (import) executes.

Return Some(Value) to short-circuit with a recorded value (replay). Return None to proceed with normal execution (recording/passthrough).

Source

fn after_import( &self, interface: &str, function: &str, input: &Value, output: &Value, )

Called after a host function (import) returns normally.

Source

fn before_export(&self, function: &str, input: &Value) -> Option<Value>

Called before an export function is called.

Return Some(Value) to skip the actual WASM call (replay). Return None to proceed normally.

Source

fn after_export(&self, function: &str, input: &Value, output: &Value)

Called after an export function returns.

Implementors§