29 lines
812 B
Rust
29 lines
812 B
Rust
use {
|
|
super::Package,
|
|
crate::Version,
|
|
serde::{Deserialize, Serialize},
|
|
};
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
|
pub struct Dependency {
|
|
pub name: String,
|
|
pub version: (Option<Version>, Option<Version>),
|
|
}
|
|
|
|
impl Dependency {
|
|
#[allow(clippy::must_use_candidate)]
|
|
pub fn satisfied(&self, package: &Package) -> bool {
|
|
if self.name.as_str() == package.name.as_str() {
|
|
match &self.version {
|
|
(Some(low), Some(high)) => &package.version >= low && &package.version < high,
|
|
(Some(low), None) => &package.version >= low,
|
|
(None, Some(high)) => &package.version < high,
|
|
// no version requirements
|
|
_ => true,
|
|
}
|
|
} else {
|
|
false
|
|
}
|
|
}
|
|
}
|