Trait VxPlugin

Source
pub trait VxPlugin: Send + Sync {
Show 18 methods // Required method fn name(&self) -> &str; // Provided methods fn description(&self) -> &str { ... } fn version(&self) -> &str { ... } fn author(&self) -> Option<&str> { ... } fn homepage(&self) -> Option<&str> { ... } fn tools(&self) -> Vec<Box<dyn VxTool>> { ... } fn package_managers(&self) -> Vec<Box<dyn VxPackageManager>> { ... } fn initialize<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn shutdown<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn supports_tool(&self, tool_name: &str) -> bool { ... } fn supports_package_manager(&self, pm_name: &str) -> bool { ... } fn get_tool(&self, tool_name: &str) -> Option<Box<dyn VxTool>> { ... } fn get_package_manager( &self, pm_name: &str, ) -> Option<Box<dyn VxPackageManager>> { ... } fn is_compatible_with(&self, vx_version: &str) -> bool { ... } fn dependencies(&self) -> Vec<&str> { ... } fn config_schema(&self) -> Option<Value> { ... } fn validate_config(&self, _config: &Value) -> Result<()> { ... } fn metadata(&self) -> HashMap<String, String> { ... }
}
Expand description

Combined plugin trait that can provide both tools and package managers

This is the main trait that plugin developers implement to register their functionality. A plugin can provide tools, package managers, or both.

§Example

use vx_plugin::{VxPlugin, VxTool, VxPackageManager, Result};
use async_trait::async_trait;

struct MyPlugin;

#[async_trait]
impl VxPlugin for MyPlugin {
    fn name(&self) -> &str {
        "my-plugin"
    }

    fn description(&self) -> &str {
        "A plugin that provides custom tools and package managers"
    }

    fn tools(&self) -> Vec<Box<dyn VxTool>> {
        // Return your tool implementations
        vec![]
    }

    fn package_managers(&self) -> Vec<Box<dyn VxPackageManager>> {
        // Return your package manager implementations
        vec![]
    }
}

Required Methods§

Source

fn name(&self) -> &str

Plugin name (required)

This should be a unique identifier for the plugin.

Provided Methods§

Source

fn description(&self) -> &str

Plugin description (optional)

A human-readable description of what this plugin provides.

Source

fn version(&self) -> &str

Plugin version (optional)

The version of this plugin implementation.

Source

fn author(&self) -> Option<&str>

Plugin author (optional)

Information about who created this plugin.

Source

fn homepage(&self) -> Option<&str>

Plugin homepage or repository URL (optional)

URL where users can find more information about this plugin.

Source

fn tools(&self) -> Vec<Box<dyn VxTool>>

Get all tools provided by this plugin

Return a vector of tool implementations that this plugin provides. Return an empty vector if this plugin doesn’t provide any tools.

Source

fn package_managers(&self) -> Vec<Box<dyn VxPackageManager>>

Get all package managers provided by this plugin

Return a vector of package manager implementations that this plugin provides. Return an empty vector if this plugin doesn’t provide any package managers.

Source

fn initialize<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Initialize the plugin (optional)

This method is called when the plugin is loaded. Use it to perform any necessary setup, such as checking dependencies or initializing internal state.

Source

fn shutdown<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Shutdown the plugin (optional)

This method is called when the plugin is being unloaded. Use it to perform cleanup operations.

Source

fn supports_tool(&self, tool_name: &str) -> bool

Check if this plugin supports a specific tool

Default implementation checks all tools provided by this plugin, including their aliases.

Source

fn supports_package_manager(&self, pm_name: &str) -> bool

Check if this plugin supports a specific package manager

Default implementation checks all package managers provided by this plugin.

Source

fn get_tool(&self, tool_name: &str) -> Option<Box<dyn VxTool>>

Get a specific tool by name

Returns the first tool that matches the given name or alias. Note: This method returns an owned Box since the tools are owned by the plugin.

Source

fn get_package_manager( &self, pm_name: &str, ) -> Option<Box<dyn VxPackageManager>>

Get a specific package manager by name

Returns the first package manager that matches the given name. Note: This method returns an owned Box since the package managers are owned by the plugin.

Source

fn is_compatible_with(&self, vx_version: &str) -> bool

Check plugin compatibility with the current vx version

Override this to implement version compatibility checks. The default implementation accepts all versions.

Source

fn dependencies(&self) -> Vec<&str>

Get plugin dependencies

Return a list of other plugins that this plugin depends on. The default implementation has no dependencies.

Source

fn config_schema(&self) -> Option<Value>

Get plugin configuration schema

Return a JSON schema describing the configuration options that this plugin accepts. The default implementation has no configuration.

Source

fn validate_config(&self, _config: &Value) -> Result<()>

Validate plugin configuration

Check if the provided configuration is valid for this plugin. The default implementation accepts any configuration.

Source

fn metadata(&self) -> HashMap<String, String>

Additional metadata for the plugin (optional)

Override this to provide plugin-specific metadata such as supported platforms, feature flags, etc.

Implementors§