VtxPlugin

Trait VtxPlugin 

Source
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

A high-level trait for defining Vtx plugins with minimal boilerplate.

The bindings::Guest trait generated by wit-bindgen requires implementing all exported functions. This trait provides default implementations for common methods and allows returning VtxResult directly in handle and handle_event for better error handling ergonomics.

Required Methods§

Provided Methods§

Source

fn handle(_req: Request) -> VtxResult<Response>

Source

fn handle_event(_event: PluginEvent) -> VtxResult<()>

Source

fn get_migrations() -> Vec<String>

Source

fn get_resources() -> Vec<String>

Source

fn authenticate(_headers: &[(String, String)]) -> VtxResult<UserContext>

Performs authentication based on request headers.

By default, this returns 401 (Unauthorized), indicating that this plugin does not handle authentication. This design ensures it does not block other plugins in the chain of responsibility that might handle authentication.

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.

Implementors§