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§
Sourcefn before_import(
&self,
interface: &str,
function: &str,
input: &Value,
) -> Option<Value>
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).
Sourcefn after_import(
&self,
interface: &str,
function: &str,
input: &Value,
output: &Value,
)
fn after_import( &self, interface: &str, function: &str, input: &Value, output: &Value, )
Called after a host function (import) returns normally.
Sourcefn before_export(&self, function: &str, input: &Value) -> Option<Value>
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.
Sourcefn after_export(&self, function: &str, input: &Value, output: &Value)
fn after_export(&self, function: &str, input: &Value, output: &Value)
Called after an export function returns.