pub trait VtxPlugin {
// Required methods
fn get_manifest() -> Manifest;
fn get_capabilities() -> Capabilities;
// Provided methods
fn handle(_req: Request) -> VtxResult<Response> { ... }
fn handle_event(_event: PluginEvent) -> VtxResult<()> { ... }
fn get_migrations() -> Vec<String> { ... }
fn get_resources() -> Vec<String> { ... }
fn authenticate(_headers: &[(String, String)]) -> VtxResult<UserContext> { ... }
}Expand description
更低样板的插件入口 Trait。
wit-bindgen 生成的 bindings::Guest 要求实现所有导出函数;
此 Trait 为常见方法提供默认实现,并允许在 handle/handle_event 中直接返回 VtxResult。
Required Methods§
fn get_manifest() -> Manifest
fn get_capabilities() -> Capabilities
Provided Methods§
fn handle(_req: Request) -> VtxResult<Response>
fn handle_event(_event: PluginEvent) -> VtxResult<()>
fn get_migrations() -> Vec<String>
fn get_resources() -> Vec<String>
Sourcefn authenticate(_headers: &[(String, String)]) -> VtxResult<UserContext>
fn authenticate(_headers: &[(String, String)]) -> VtxResult<UserContext>
默认返回 401,表示该插件不处理鉴权(不会阻断责任链中的其它插件)。
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.