VxPackageManager

Trait VxPackageManager 

Source
pub trait VxPackageManager: Send + Sync {
Show 23 methods // Required methods fn name(&self) -> &str; fn ecosystem(&self) -> Ecosystem; fn install_packages<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, packages: &'life1 [PackageSpec], project_path: &'life2 Path, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; // Provided methods fn description(&self) -> &str { ... } fn is_available<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn is_preferred_for_project(&self, project_path: &Path) -> bool { ... } fn get_config_files(&self) -> Vec<&str> { ... } fn remove_packages<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, packages: &'life1 [String], project_path: &'life2 Path, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait { ... } fn update_packages<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, packages: &'life1 [String], project_path: &'life2 Path, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait { ... } fn list_packages<'life0, 'life1, 'async_trait>( &'life0 self, project_path: &'life1 Path, ) -> Pin<Box<dyn Future<Output = Result<Vec<PackageInfo>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn search_packages<'life0, 'life1, 'async_trait>( &'life0 self, query: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<PackageInfo>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn run_command<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, command: &'life1 [&'life2 str], args: &'life3 [String], project_path: &'life4 Path, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait { ... } fn default_list_packages<'life0, 'life1, 'async_trait>( &'life0 self, _project_path: &'life1 Path, ) -> Pin<Box<dyn Future<Output = Result<Vec<PackageInfo>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn run_search_command<'life0, 'life1, 'async_trait>( &'life0 self, _query: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<PackageInfo>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn get_install_command(&self) -> Vec<&str> { ... } fn get_add_command(&self) -> Vec<&str> { ... } fn get_remove_command(&self) -> Vec<&str> { ... } fn get_update_command(&self) -> Vec<&str> { ... } fn get_list_command(&self) -> Vec<&str> { ... } fn get_search_command(&self) -> Vec<&str> { ... } fn get_config(&self) -> PackageManagerConfig { ... } fn run_command_with_code<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, command: &'life1 [&'life2 str], args: &'life3 [String], project_path: &'life4 Path, ) -> Pin<Box<dyn Future<Output = Result<i32>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait { ... } fn metadata(&self) -> HashMap<String, String> { ... }
}
Expand description

Simplified trait for implementing package manager support

This trait provides a high-level interface for package managers, with sensible defaults for common operations.

§Required Methods

  • name(): Return the package manager name
  • ecosystem(): Return the ecosystem this package manager belongs to
  • install_packages(): Install packages in a project

§Optional Methods

All other methods have default implementations, but can be overridden for package manager-specific behavior.

§Example

use vx_plugin::{VxPackageManager, Ecosystem, PackageSpec, Result};
use async_trait::async_trait;
use std::path::Path;

struct MyPackageManager;

#[async_trait]
impl VxPackageManager for MyPackageManager {
    fn name(&self) -> &str {
        "mypm"
    }

    fn ecosystem(&self) -> Ecosystem {
        Ecosystem::Node
    }

    async fn install_packages(&self, packages: &[PackageSpec], project_path: &Path) -> Result<()> {
        // Install packages using your package manager
        Ok(())
    }
}

Required Methods§

Source

fn name(&self) -> &str

Package manager name (required)

This should be the command name used to invoke the package manager, such as “npm”, “pip”, “cargo”, etc.

Source

fn ecosystem(&self) -> Ecosystem

Ecosystem this package manager belongs to (required)

Indicates which programming language or platform ecosystem this package manager serves.

Source

fn install_packages<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, packages: &'life1 [PackageSpec], project_path: &'life2 Path, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Install packages (main method to implement)

This is the primary method that package manager implementations must provide. It should install the specified packages in the given project directory.

§Arguments
  • packages - List of package specifications to install
  • project_path - Path to the project directory

Provided Methods§

Source

fn description(&self) -> &str

Description of the package manager (optional)

A human-readable description of what this package manager does.

Source

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

Check if this package manager is available on the system

Default implementation checks if the executable exists in PATH.

Source

fn is_preferred_for_project(&self, project_path: &Path) -> bool

Check if this package manager should be used for a project

Override this to detect project-specific files (package.json, Cargo.toml, etc.) The default implementation checks for common configuration files.

Source

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

Get configuration files that indicate this package manager should be used

Override this to return the configuration files specific to your package manager. For example, npm would return [“package.json”], cargo would return [“Cargo.toml”].

Source

fn remove_packages<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, packages: &'life1 [String], project_path: &'life2 Path, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Remove packages

Default implementation uses the “remove” command. Override if your package manager uses different commands.

Source

fn update_packages<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, packages: &'life1 [String], project_path: &'life2 Path, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Update packages

Default implementation uses the “update” command. If no packages are specified, updates all packages.

Source

fn list_packages<'life0, 'life1, 'async_trait>( &'life0 self, project_path: &'life1 Path, ) -> Pin<Box<dyn Future<Output = Result<Vec<PackageInfo>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List installed packages

Default implementation attempts to parse common configuration files or run list commands. Override for package manager-specific logic.

Source

fn search_packages<'life0, 'life1, 'async_trait>( &'life0 self, query: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<PackageInfo>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Search for packages

Default implementation runs the package manager’s search command. Override for custom search logic or API integration.

Source

fn run_command<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, command: &'life1 [&'life2 str], args: &'life3 [String], project_path: &'life4 Path, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Run a package manager command with arguments

This is a utility method that executes the package manager with the specified command and arguments in the given project directory.

Source

fn default_list_packages<'life0, 'life1, 'async_trait>( &'life0 self, _project_path: &'life1 Path, ) -> Pin<Box<dyn Future<Output = Result<Vec<PackageInfo>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Default implementation for listing packages

This method provides a fallback implementation that attempts to parse common configuration files. Override for better integration.

Source

fn run_search_command<'life0, 'life1, 'async_trait>( &'life0 self, _query: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<PackageInfo>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Default implementation for searching packages

This method runs the package manager’s search command and attempts to parse the output. Override for API-based search or custom parsing.

Source

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

Get the command to install packages

Override this if your package manager uses a different command for installation. Most package managers use “install”, but some might use “add” or other commands.

Source

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

Get the command to add new packages

Override this if your package manager distinguishes between installing existing dependencies and adding new ones. Some package managers use “add” for new packages and “install” for existing dependencies.

Source

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

Get the command to remove packages

Override this if your package manager uses a different command for removal.

Source

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

Get the command to update packages

Override this if your package manager uses a different command for updates.

Source

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

Get the command to list packages

Override this if your package manager has a specific list command.

Source

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

Get the command to search packages

Override this if your package manager uses a different search command.

Source

fn get_config(&self) -> PackageManagerConfig

Get package manager configuration

Returns configuration information about this package manager.

Source

fn run_command_with_code<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, command: &'life1 [&'life2 str], args: &'life3 [String], project_path: &'life4 Path, ) -> Pin<Box<dyn Future<Output = Result<i32>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Run a package manager command and return the exit code

Similar to run_command but returns the exit code instead of failing on non-zero codes.

Source

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

Additional metadata for the package manager (optional)

Override this to provide package manager-specific metadata such as supported features, configuration options, etc.

Implementors§