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::literal_path::LiteralPath;
6
7/// The part of a rule a location falls in.
8#[derive(
9    Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize,
10)]
11#[serde(deny_unknown_fields)]
12pub enum RuleSite {
13    /// The rule head atom.
14    Head,
15    /// A literal in the rule body.
16    Body(LiteralPath),
17}
18
19impl fmt::Display for RuleSite {
20    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
21        match self {
22            Self::Head => f.write_str("head"),
23            Self::Body(path) => path.fmt(f),
24        }
25    }
26}