use std::fmt::{Display, Formatter};
use std::str::FromStr;
#[derive(Copy, Clone, Debug, PartialEq, Default)]
pub enum ShaclValidationMode {
#[default]
Native,
#[cfg(feature = "sparql")]
Sparql,
}
impl Display for ShaclValidationMode {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
ShaclValidationMode::Native => write!(f, "native"),
#[cfg(feature = "sparql")]
ShaclValidationMode::Sparql => write!(f, "sparql"),
}
}
}
impl FromStr for ShaclValidationMode {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_lowercase().as_str() {
"native" => Ok(Self::Native),
#[cfg(feature = "sparql")]
"sparql" => Ok(Self::Sparql),
other => Err(format!("Unsupported SHACL validation mode: {other}")),
}
}
}