use std::fmt;
use crate::DatalogFeature;
#[derive(
Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize,
)]
pub enum HeadForm {
Atomic,
Conjunctive,
Existential,
Disjunctive,
Inconsistency,
}
impl HeadForm {
pub const ALL: &'static [Self] = &[
Self::Atomic,
Self::Conjunctive,
Self::Existential,
Self::Disjunctive,
Self::Inconsistency,
];
#[must_use]
pub const fn required_feature(self) -> Option<DatalogFeature> {
match self {
Self::Atomic => None,
Self::Conjunctive => Some(DatalogFeature::ConjunctiveHeads),
Self::Existential => Some(DatalogFeature::ExistentialHeads),
Self::Disjunctive => Some(DatalogFeature::DisjunctiveHeads),
Self::Inconsistency => Some(DatalogFeature::InconsistencyConstraints),
}
}
#[must_use]
pub const fn as_str(self) -> &'static str {
match self {
Self::Atomic => "atomic",
Self::Conjunctive => "conjunctive",
Self::Existential => "existential",
Self::Disjunctive => "disjunctive",
Self::Inconsistency => "inconsistency",
}
}
}
impl fmt::Display for HeadForm {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.as_str())
}
}