FormatHandler

Trait FormatHandler 

Source
pub trait FormatHandler: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn can_handle(&self, file_path: &Path) -> bool;
    fn extract<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        source_path: &'life1 Path,
        target_dir: &'life2 Path,
        progress: &'life3 ProgressContext,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<PathBuf>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;

    // Provided methods
    fn get_executable_name(&self, tool_name: &str) -> String { ... }
    fn find_executables(
        &self,
        dir: &Path,
        tool_name: &str,
    ) -> Result<Vec<PathBuf>> { ... }
    fn is_executable(&self, path: &Path) -> bool { ... }
    fn make_executable(&self, path: &Path) -> Result<()> { ... }
}
Expand description

Trait for handling different archive formats and installation methods

Required Methods§

Source

fn name(&self) -> &str

Get the name of this format handler

Source

fn can_handle(&self, file_path: &Path) -> bool

Check if this handler can process the given file

Source

fn extract<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, source_path: &'life1 Path, target_dir: &'life2 Path, progress: &'life3 ProgressContext, ) -> Pin<Box<dyn Future<Output = Result<Vec<PathBuf>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Extract or install the file to the target directory

Provided Methods§

Source

fn get_executable_name(&self, tool_name: &str) -> String

Get the expected executable name for a tool

Source

fn find_executables(&self, dir: &Path, tool_name: &str) -> Result<Vec<PathBuf>>

Find executable files in the extracted directory

Source

fn is_executable(&self, path: &Path) -> bool

Check if a file is executable

Source

fn make_executable(&self, path: &Path) -> Result<()>

Make a file executable on Unix systems

Implementors§