aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/repository/vcs/vcs_driver_interface.rs
blob: fb10d0f251d0a89662bdf3a0ac3aaff50594fd72 (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
//! ref: composer/src/Composer/Repository/Vcs/VcsDriverInterface.php

use crate::config::Config;
use crate::io::IOInterface;
use chrono::{DateTime, FixedOffset};
use indexmap::IndexMap;
use shirabe_php_shim::PhpMixed;
use std::cell::RefCell;
use std::rc::Rc;

pub trait VcsDriverInterface: std::fmt::Debug {
    fn initialize(&mut self) -> anyhow::Result<()>;

    fn get_composer_information(
        &mut self,
        identifier: &str,
    ) -> anyhow::Result<Option<IndexMap<String, PhpMixed>>>;

    fn get_file_content(&mut self, file: &str, identifier: &str) -> anyhow::Result<Option<String>>;

    fn get_change_date(
        &mut self,
        identifier: &str,
    ) -> anyhow::Result<Option<DateTime<FixedOffset>>>;

    fn get_root_identifier(&mut self) -> anyhow::Result<String>;

    fn get_branches(&mut self) -> anyhow::Result<IndexMap<String, String>>;

    fn get_tags(&mut self) -> anyhow::Result<IndexMap<String, String>>;

    fn get_dist(&self, identifier: &str) -> Option<IndexMap<String, String>>;

    fn get_source(&self, identifier: &str) -> IndexMap<String, String>;

    fn get_url(&self) -> String;

    fn has_composer_file(&mut self, identifier: &str) -> anyhow::Result<bool>;

    fn cleanup(&mut self) -> anyhow::Result<()>;

    fn supports(
        io: Rc<RefCell<dyn IOInterface>>,
        config: Rc<RefCell<Config>>,
        url: &str,
        deep: bool,
    ) -> anyhow::Result<bool>
    where
        Self: Sized;
}