pub enum GroundTerm {
Constant(ConstantSymbol),
TripleTerm(Box<GroundAtom>),
}Expand description
Ground term — the value form of a Term
with all variables substituted. Used as the cell type inside
tuples so an evaluator can store both flat
constant-only facts and quoted-triple facts (TT1).
Constant corresponds to the
Term::Constant form;
TripleTerm is the value form of
Term::TripleTerm —
a GroundAtom whose argument list contains only further
GroundTerm values (no variables, recursively).
Total order: Constant(_) < TripleTerm(_). Within each
variant, the inner symbol or atom’s lexicographic order
determines the result. This is the determinism contract
an evaluator can rely on when serialising grounded facts.
Variants§
Constant(ConstantSymbol)
Ground constant — the value form of
Term::Constant.
TripleTerm(Box<GroundAtom>)
Ground quoted-triple term — the value form of
Term::TripleTerm.
Contains a GroundAtom whose argument list contains
only further GroundTerm values; recursive nesting is
bounded by
MAX_TRIPLE_TERM_NESTING
(enforced at IR
Program::validate
time, before grounding).
Implementations§
Source§impl GroundTerm
impl GroundTerm
Sourcepub fn constant(c: ConstantSymbol) -> Self
pub fn constant(c: ConstantSymbol) -> Self
Construct a flat-constant ground term. Convenience for
the common case where the underlying value is a plain
ConstantSymbol.
Sourcepub fn as_constant(&self) -> Option<&ConstantSymbol>
pub fn as_constant(&self) -> Option<&ConstantSymbol>
Pull out the wrapped ConstantSymbol when this is the
constant form. Returns None for GroundTerm::TripleTerm.
Source§impl GroundTerm
impl GroundTerm
Sourcepub fn try_triple_term(atom: GroundAtom) -> Result<Self, TermShapeError>
pub fn try_triple_term(atom: GroundAtom) -> Result<Self, TermShapeError>
Construct a grounded structured term with checked nesting.
§Errors
Rejects excessive triple-term nesting.
Sourcepub fn validate_structure(&self) -> Result<(), TermShapeError>
pub fn validate_structure(&self) -> Result<(), TermShapeError>
Check the same nesting invariant used before grounding a program.
§Errors
Rejects excessive triple-term nesting.
Trait Implementations§
Source§impl Clone for GroundTerm
impl Clone for GroundTerm
Source§impl Debug for GroundTerm
impl Debug for GroundTerm
Source§impl<'de> Deserialize<'de> for GroundTerm
impl<'de> Deserialize<'de> for GroundTerm
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for GroundTerm
Display a GroundTerm: constants as their raw symbol,
quoted-triple terms as << s p o >> per N-Triples-star
syntax (mirroring Term’s display
contract).
impl Display for GroundTerm
Display a GroundTerm: constants as their raw symbol,
quoted-triple terms as << s p o >> per N-Triples-star
syntax (mirroring Term’s display
contract).