aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-semver/src/constraint/constraint_interface.rs
blob: f04ed2aa4b1f57f9c6a34a7900aa407ddde5553b (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
//! ref: composer/vendor/composer/semver/src/Constraint/ConstraintInterface.php

use crate::constraint::Bound;

pub trait ConstraintInterface: std::fmt::Debug {
    fn matches(&self, provider: &dyn ConstraintInterface) -> bool;

    fn compile(&self, other_operator: i64) -> String;

    fn get_upper_bound(&self) -> Bound;

    fn get_lower_bound(&self) -> Bound;

    fn get_pretty_string(&self) -> String;

    fn set_pretty_string(&mut self, pretty_string: Option<String>);

    fn __to_string(&self) -> String;

    // Rust-specific helpers for instanceof checks in MultiConstraint::matches and optimizeConstraints.
    fn is_disjunctive(&self) -> bool {
        false
    }

    /// Rust-specific helper: PHP `$c instanceof Constraint` check.
    fn is_constraint(&self) -> bool {
        false
    }

    /// Rust-specific helper: PHP `$c->getOperator()`. Only meaningful when `is_constraint()` is true.
    fn get_operator(&self) -> &'static str {
        ""
    }

    /// Rust-specific helper: PHP `$c->getVersion()`. Only meaningful when `is_constraint()` is true.
    fn get_version(&self) -> &str {
        ""
    }

    fn clone_box(&self) -> Box<dyn ConstraintInterface>;

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