Skip to main content

inference_engine/
lib.rs

1#![doc = include_str!("../README.md")]
2
3use datalog_structural_model::Program;
4use rdf_reasoning::{Exclusion, Preset, PresetParseError};
5use serde::Serialize;
6
7/// An exact shared RDF profile, compiled into portable checked Datalog rules.
8///
9/// This is a program description, not an evaluated closure or engine capability claim.
10#[derive(Debug, Serialize)]
11pub struct CompiledProfile {
12    /// The selected semantic contract.
13    pub preset: Preset,
14    /// The shared rule catalogue's checked program.
15    pub program: Program,
16    /// Obligations deliberately excluded by this profile.
17    pub exclusions: &'static [Exclusion],
18}
19
20impl CompiledProfile {
21    /// Compile the finite rule catalogue for this preset without loading graph data.
22    #[must_use]
23    pub fn new(preset: Preset) -> Self {
24        Self {
25            preset,
26            program: preset.program(),
27            exclusions: preset.exclusions(),
28        }
29    }
30}
31
32/// Compile a named shared RDF profile, rejecting unknown or unsupported selectors.
33///
34/// # Errors
35/// Returns the shared catalogue's typed parse error for an unsupported selector.
36pub fn compile_profile(selector: &str) -> Result<CompiledProfile, PresetParseError> {
37    selector.parse().map(CompiledProfile::new)
38}
39
40/// Enumerate exactly the finite set of available rule-profile selectors.
41pub fn profiles() -> impl ExactSizeIterator<Item = &'static str> {
42    Preset::ALL.iter().map(|preset| preset.name())
43}