pub mod xcsp3_core {
use std::fmt::{Display, Formatter};
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ObjectiveError {
UnknownScope,
UnknownCoeffs,
UnknownType,
UnknownTarget,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ParseObjectivesError {
pub msg: String,
pub r#type: ObjectiveError,
}
impl Display for ParseObjectivesError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}: {}", self.r#type, self.msg)
}
}
impl ParseObjectivesError {
pub(crate) fn get_scope_error(s: &str) -> ParseObjectivesError {
const WEBSITE: &str = " please visit http://xcsp.org/specifications/objectives/";
ParseObjectivesError {
msg: (s.to_owned() + WEBSITE),
r#type: ObjectiveError::UnknownScope,
}
}
pub(crate) fn get_coeffs_error(s: &str) -> ParseObjectivesError {
const WEBSITE: &str = " please visit http://xcsp.org/specifications/objectives/";
ParseObjectivesError {
msg: (s.to_owned() + WEBSITE),
r#type: ObjectiveError::UnknownCoeffs,
}
}
pub(crate) fn get_type_error(s: &str) -> ParseObjectivesError {
const WEBSITE: &str = " please visit http://xcsp.org/specifications/objectives/";
ParseObjectivesError {
msg: (s.to_owned() + WEBSITE),
r#type: ObjectiveError::UnknownType,
}
}
pub(crate) fn get_target_error(s: &str) -> ParseObjectivesError {
const WEBSITE: &str = " please visit http://xcsp.org/specifications/objectives/";
ParseObjectivesError {
msg: (s.to_owned() + WEBSITE),
r#type: ObjectiveError::UnknownTarget,
}
}
}
}