Skip to main content

PluginRuntime

Trait PluginRuntime 

Source
pub trait PluginRuntime {
    type Instance;
    type Error: Error;

    // Required methods
    fn adapter(&self) -> PluginAdapter;
    fn load(
        &self,
        manifest: PluginManifest,
        bytes: &[u8],
    ) -> Result<Self::Instance, Self::Error>;
}
Expand description

Generic execution backend for a plugin artifact. 插件工件的泛型执行后端。

The associated instance keeps dispatch static: a native, WASM, or process adapter can be selected by the host without putting every plugin implementation behind one global trait object. 使用关联类型保持静态分发:宿主可以选择 native、WASM 或进程适配器, 不必把所有插件实现塞进一个全局 trait object。

Required Associated Types§

Source

type Instance

The loaded form a caller drives once load has succeeded. load 成功后调用方驱动的已加载实例类型。

Source

type Error: Error

Why loading failed. Structured so an adapter reports its own error type instead of flattening every failure into a string. 加载失败的原因。结构化后适配器报告自己的错误类型,而不必把每种失败压平成字符串。

Required Methods§

Source

fn adapter(&self) -> PluginAdapter

Report which isolation mode this runtime provides. 报告本运行时所提供的隔离方式。

Source

fn load( &self, manifest: PluginManifest, bytes: &[u8], ) -> Result<Self::Instance, Self::Error>

Load one manifest’s bytes, surfacing the adapter’s own failure type. 加载某个 manifest 的字节,失败时给出适配器自己的错误类型。

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§