aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/repository/lock_array_repository.rs
blob: cbc8564170c770093503e0e5ef1ccaf7c22292b9 (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
//! ref: composer/src/Composer/Repository/LockArrayRepository.php

use crate::package::BasePackageHandle;
use crate::package::PackageInterfaceHandle;
use crate::repository::ArrayRepository;
use crate::repository::CanonicalPackagesTrait;
use crate::repository::{
    FindPackageConstraint, LoadPackagesResult, ProviderInfo, RepositoryInterface, SearchResult,
};
use indexmap::IndexMap;
use shirabe_php_shim::Countable;
use shirabe_semver::constraint::AnyConstraint;

#[derive(Debug)]
pub struct LockArrayRepository {
    inner: ArrayRepository,
}

impl CanonicalPackagesTrait for LockArrayRepository {
    fn get_packages(&self) -> Vec<PackageInterfaceHandle> {
        todo!()
    }
}

impl LockArrayRepository {
    pub fn clone_box(&self) -> Box<dyn RepositoryInterface> {
        todo!()
    }
}

impl Countable for LockArrayRepository {
    fn count(&self) -> i64 {
        self.inner.count()
    }
}

impl RepositoryInterface for LockArrayRepository {
    fn has_package(&self, package: PackageInterfaceHandle) -> bool {
        self.inner.has_package(package)
    }

    fn find_package(
        &self,
        name: &str,
        constraint: FindPackageConstraint,
    ) -> Option<BasePackageHandle> {
        self.inner.find_package(name, constraint)
    }

    fn find_packages(
        &self,
        name: &str,
        constraint: Option<FindPackageConstraint>,
    ) -> Vec<BasePackageHandle> {
        self.inner.find_packages(name, constraint)
    }

    fn get_packages(&self) -> Vec<BasePackageHandle> {
        RepositoryInterface::get_packages(&self.inner)
    }

    fn load_packages(
        &self,
        package_name_map: IndexMap<String, Option<AnyConstraint>>,
        acceptable_stabilities: IndexMap<String, i64>,
        stability_flags: IndexMap<String, i64>,
        already_loaded: IndexMap<String, IndexMap<String, PackageInterfaceHandle>>,
    ) -> LoadPackagesResult {
        self.inner.load_packages(
            package_name_map,
            acceptable_stabilities,
            stability_flags,
            already_loaded,
        )
    }

    fn search(&self, query: String, mode: i64, r#type: Option<String>) -> Vec<SearchResult> {
        self.inner.search(query, mode, r#type)
    }

    fn get_providers(&self, package_name: String) -> IndexMap<String, ProviderInfo> {
        self.inner.get_providers(package_name)
    }

    fn get_repo_name(&self) -> String {
        "lock repo".to_string()
    }

    fn as_any(&self) -> &dyn std::any::Any {
        self
    }
}