Skip to main content

datalog_structural_model/position/
rule_site.rs

1//! [`RuleSite`] — head or body location inside one rule.
2
3use std::fmt;
4
5use super::head_path::HeadAtomPath;
6use super::literal_path::LiteralPath;
7
8/// The part of a rule a location falls in.
9#[derive(
10    Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize,
11)]
12#[serde(deny_unknown_fields)]
13pub enum RuleSite {
14    /// One atom of the rule head.
15    Head(HeadAtomPath),
16    /// A literal in the rule body.
17    Body(LiteralPath),
18}
19
20impl fmt::Display for RuleSite {
21    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
22        match self {
23            Self::Head(path) => path.fmt(f),
24            Self::Body(path) => path.fmt(f),
25        }
26    }
27}