change dependency requirement structure

This commit is contained in:
Aiden McClelland
2021-09-27 16:23:24 -06:00
parent 65e4fb5dc4
commit 72cc6b1b2a
3 changed files with 17 additions and 4 deletions

View File

@@ -336,7 +336,7 @@ pub fn configure<'a, Db: DbHandle>(
.0
.iter()
.filter_map(|(id, info)| {
if info.optional.is_none() {
if info.requirement.required() {
Some((id.clone(), CurrentDependencyInfo::default()))
} else {
None

View File

@@ -116,12 +116,25 @@ impl HasModel for Dependencies {
type Model = MapModel<Self>;
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
#[serde(tag = "type")]
pub enum DependencyRequirement {
OptIn { how: String },
OptOut { how: String },
Required,
}
impl DependencyRequirement {
pub fn required(&self) -> bool {
matches!(self, &DependencyRequirement::Required)
}
}
#[derive(Clone, Debug, Deserialize, Serialize, HasModel)]
#[serde(rename_all = "kebab-case")]
pub struct DepInfo {
pub version: VersionRange,
pub optional: Option<String>,
pub recommended: bool,
pub requirement: DependencyRequirement,
pub description: Option<String>,
pub critical: bool,
#[serde(default)]

View File

@@ -532,7 +532,7 @@ pub async fn install_s9pk<R: AsyncRead + AsyncSeek + Unpin>(
.0
.iter()
.filter_map(|(id, info)| {
if info.optional.is_none() {
if info.requirement.required() {
Some((id.clone(), CurrentDependencyInfo::default()))
} else {
None