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§
Provided Methods§
Sourcefn description(&self) -> &str
fn description(&self) -> &str
Plugin description (optional)
A human-readable description of what this plugin provides.
Plugin author (optional)
Information about who created this plugin.
Sourcefn homepage(&self) -> Option<&str>
fn homepage(&self) -> Option<&str>
Plugin homepage or repository URL (optional)
URL where users can find more information about this plugin.
Sourcefn tools(&self) -> Vec<Box<dyn VxTool>>
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.
Sourcefn package_managers(&self) -> Vec<Box<dyn VxPackageManager>>
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.
Sourcefn initialize<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
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.
Sourcefn shutdown<'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,
Shutdown the plugin (optional)
This method is called when the plugin is being unloaded. Use it to perform cleanup operations.
Sourcefn supports_tool(&self, tool_name: &str) -> bool
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.
Sourcefn supports_package_manager(&self, pm_name: &str) -> bool
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.
Sourcefn get_tool(&self, tool_name: &str) -> Option<Box<dyn VxTool>>
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.
Sourcefn get_package_manager(
&self,
pm_name: &str,
) -> Option<Box<dyn VxPackageManager>>
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.
Sourcefn is_compatible_with(&self, vx_version: &str) -> bool
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.
Sourcefn dependencies(&self) -> Vec<&str>
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.
Sourcefn config_schema(&self) -> Option<Value>
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.
Sourcefn validate_config(&self, _config: &Value) -> Result<()>
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.