Skip to main content

Guest

Trait Guest 

Source
pub trait Guest {
    // Required methods
    fn init() -> Result<Capabilities, InitError>;
    fn info() -> PluginInfo;
    fn handle(request: PluginRequest) -> HandleResult;
    fn shutdown();
}

Required Methods§

Source

fn init() -> Result<Capabilities, InitError>

Initialize the plugin with provided configuration. Called once when the plugin is loaded. Returns capabilities the plugin requires.

The plugin should:

  1. Read any required configuration
  2. Initialize internal state
  3. Return the capabilities it needs

If initialization fails, the plugin will not be loaded.

Source

fn info() -> PluginInfo

Return plugin metadata. Called after successful initialization. This information is used for logging, metrics, and management.

Source

fn handle(request: PluginRequest) -> HandleResult

Handle an incoming request. Called for each request that matches the plugin’s routing rules.

The plugin should:

  1. Examine the request
  2. Process it or decide to pass through
  3. Return an appropriate result

Possible returns:

  • response: Plugin handled the request, return the response
  • pass-through: Plugin chose not to handle, continue to next handler
  • error: Plugin encountered an error processing the request
Source

fn shutdown()

Graceful shutdown hook. Called when the plugin is being unloaded. Plugins should clean up any resources. This is a best-effort call - plugins may be terminated without shutdown if they don’t respond in time.

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§