aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/repository/version_cache_interface.rs
blob: 65e5195764f7415dbab0111adfbb3fb877eb1a57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//! ref: composer/src/Composer/Repository/VersionCacheInterface.php

use indexmap::IndexMap;
use shirabe_php_shim::PhpMixed;

/// Result of looking up a cached package version.
///
/// PHP's `getVersionPackage(...)` returns either an array (the package data),
/// `null` (cache miss), or `false` (cached absence). We model that as an enum.
#[derive(Debug)]
pub enum VersionCacheResult {
    /// Cache miss (PHP `null`).
    None,
    /// Cached absence (PHP `false`).
    Missing,
    /// Cached package data (PHP `array`).
    Package(IndexMap<String, PhpMixed>),
}

pub trait VersionCacheInterface: std::fmt::Debug {
    fn get_version_package(&self, version: &str, identifier: &str) -> VersionCacheResult;
}