use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct SuccessCriterion {
pub name: String,
pub description: String,
pub threshold: Option<f64>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct Constraint {
pub name: String,
pub description: String,
pub limit: String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
pub struct ManufacturingIntent {
pub objective: String,
pub success_criteria: Vec<SuccessCriterion>,
pub constraints: Vec<Constraint>,
pub metadata: HashMap<String, String>,
}
impl ManufacturingIntent {
pub fn new(objective: impl Into<String>) -> Self {
Self {
objective: objective.into(),
..Default::default()
}
}
pub fn with_criterion(mut self, name: &str, description: &str) -> Self {
self.success_criteria.push(SuccessCriterion {
name: name.to_string(),
description: description.to_string(),
threshold: None,
});
self
}
pub fn with_constraint(mut self, name: &str, limit: &str) -> Self {
self.constraints.push(Constraint {
name: name.to_string(),
description: "".to_string(),
limit: limit.to_string(),
});
self
}
}