aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/downloader/downloader_interface.rs
blob: 18026a45ee66ac8818f80996fbb1bf8781b52142 (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
//! ref: composer/src/Composer/Downloader/DownloaderInterface.php

use crate::package::PackageInterface;
use shirabe_php_shim::PhpMixed;

#[async_trait::async_trait(?Send)]
pub trait DownloaderInterface: std::fmt::Debug {
    fn get_installation_source(&self) -> String;

    async fn download(
        &self,
        package: &dyn PackageInterface,
        path: &str,
        prev_package: Option<&dyn PackageInterface>,
        output: bool,
    ) -> anyhow::Result<Option<PhpMixed>>;

    /// Convenience for the PHP default `$output = true` overload.
    async fn download3(
        &self,
        package: &dyn PackageInterface,
        path: &str,
        prev_package: Option<&dyn PackageInterface>,
    ) -> anyhow::Result<Option<PhpMixed>> {
        self.download(package, path, prev_package, true).await
    }

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

    async fn install(
        &self,
        package: &dyn PackageInterface,
        path: &str,
        output: bool,
    ) -> anyhow::Result<Option<PhpMixed>>;

    /// Convenience for the PHP default `$output = true` overload.
    async fn install2(
        &self,
        package: &dyn PackageInterface,
        path: &str,
    ) -> anyhow::Result<Option<PhpMixed>> {
        self.install(package, path, true).await
    }

    async fn update(
        &self,
        initial: &dyn PackageInterface,
        target: &dyn PackageInterface,
        path: &str,
    ) -> anyhow::Result<Option<PhpMixed>>;

    async fn remove(
        &self,
        package: &dyn PackageInterface,
        path: &str,
        output: bool,
    ) -> anyhow::Result<Option<PhpMixed>>;

    /// Convenience for the PHP default `$output = true` overload.
    async fn remove2(
        &self,
        package: &dyn PackageInterface,
        path: &str,
    ) -> anyhow::Result<Option<PhpMixed>> {
        self.remove(package, path, true).await
    }

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

    /// TODO(phase-b): runtime downcast helpers for PHP `instanceof` checks.
    fn as_change_report_interface(&self) -> Option<&dyn crate::downloader::ChangeReportInterface> {
        None
    }

    /// TODO(phase-b): runtime downcast helpers for PHP `instanceof` checks.
    fn as_vcs_capable_downloader_interface(
        &self,
    ) -> Option<&dyn crate::downloader::VcsCapableDownloaderInterface> {
        None
    }

    /// TODO(phase-b): runtime downcast helpers for PHP `instanceof` checks.
    fn as_dvcs_downloader_interface(
        &self,
    ) -> Option<&dyn crate::downloader::DvcsDownloaderInterface> {
        None
    }
}