Skip to main content

dispatch

Function dispatch 

Source
pub fn dispatch(
    ptr: usize,
    len: usize,
    f: impl Fn(&str, Value) -> Result<Value, PluginError>,
) -> u64
Expand description

plugin_dispatch 的通用实现:解析请求信封 → 调业务闭包 → 写回响应。 入参缓冲区归宿主所有(宿主 alloc、宿主 free);返回值缓冲区由本函数 alloc、宿主读完 free。

§Safety 说明

ptr/len 必须指向本线性内存里一段有效的请求字节(由宿主经 plugin_alloc 写入)。