1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//! Call Interceptor
//!
//! Provides a trait for intercepting import (host function) and export (WASM function)
//! calls at the Pack runtime level. This enables automatic recording and replay of
//! all calls without handlers needing manual recording code.
//!
//! # Recording
//!
//! A recording interceptor returns `None` from `before_import`/`before_export`
//! (allowing normal execution) and records the input/output in `after_import`/`after_export`.
//!
//! # Replay
//!
//! A replay interceptor returns `Some(recorded_output)` from `before_import`/`before_export`,
//! short-circuiting the actual call and returning the previously recorded value.
use crateValue;
use async_trait;
/// 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 async so that recording implementations can apply real
/// back-pressure on slow consumers (e.g. `.await` a bounded channel `send`
/// inside `after_import` to throttle host-function emission to a chain
/// subscriber). When invoked from the sync host-function bridges, packr
/// drives the futures via `tokio::task::block_in_place` + the current
/// `Handle`, so a tokio multi-thread runtime is required whenever an
/// interceptor is installed on the sync `func_typed` / `func_typed_result`
/// paths. The async bridges (`func_async`, `func_async_result`) are already
/// in an async context and `.await` the interceptor directly.