aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/installer/installer_interface.rs
blob: cf700be200b2e399cdb98bb3afccbcfad2ea0c49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//! ref: composer/src/Composer/Installer/InstallerInterface.php

use crate::package::package_interface::PackageInterface;
use crate::repository::installed_repository_interface::InstalledRepositoryInterface;
use shirabe_external_packages::react::promise::promise_interface::PromiseInterface;

pub trait InstallerInterface {
    fn supports(&self, package_type: &str) -> bool;

    fn is_installed(
        &self,
        repo: &dyn InstalledRepositoryInterface,
        package: &dyn PackageInterface,
    ) -> bool;

    fn download(
        &self,
        package: &dyn PackageInterface,
        prev_package: Option<&dyn PackageInterface>,
    ) -> anyhow::Result<Option<Box<dyn PromiseInterface>>>;

    fn prepare(
        &self,
        r#type: &str,
        package: &dyn PackageInterface,
        prev_package: Option<&dyn PackageInterface>,
    ) -> anyhow::Result<Option<Box<dyn PromiseInterface>>>;

    fn install(
        &mut self,
        repo: &mut dyn InstalledRepositoryInterface,
        package: &dyn PackageInterface,
    ) -> anyhow::Result<Option<Box<dyn PromiseInterface>>>;

    fn update(
        &mut self,
        repo: &mut dyn InstalledRepositoryInterface,
        initial: &dyn PackageInterface,
        target: &dyn PackageInterface,
    ) -> anyhow::Result<Option<Box<dyn PromiseInterface>>>;

    fn uninstall(
        &mut self,
        repo: &mut dyn InstalledRepositoryInterface,
        package: &dyn PackageInterface,
    ) -> anyhow::Result<Option<Box<dyn PromiseInterface>>>;

    fn cleanup(
        &self,
        r#type: &str,
        package: &dyn PackageInterface,
        prev_package: Option<&dyn PackageInterface>,
    ) -> anyhow::Result<Option<Box<dyn PromiseInterface>>>;

    fn get_install_path(&self, package: &dyn PackageInterface) -> Option<String>;

    fn clone_box(&self) -> Box<dyn InstallerInterface> {
        todo!()
    }
}