diff --git a/cozo-core/src/data/program.rs b/cozo-core/src/data/program.rs index 08e47eb2..b959b131 100644 --- a/cozo-core/src/data/program.rs +++ b/cozo-core/src/data/program.rs @@ -302,6 +302,9 @@ impl MagicFixedRuleApply { ); Ok(rel) } + pub(crate) fn relations_count(&self) -> usize { + self.rule_args.len() + } pub(crate) fn relation(&self, idx: usize) -> Result<&MagicFixedRuleRuleArg> { #[derive(Error, Diagnostic, Debug)] #[error("Cannot find a required positional argument at index {idx} for '{rule_name}'")] diff --git a/cozo-core/src/fixed_rule/mod.rs b/cozo-core/src/fixed_rule/mod.rs index f682aac5..d3f85267 100644 --- a/cozo-core/src/fixed_rule/mod.rs +++ b/cozo-core/src/fixed_rule/mod.rs @@ -329,6 +329,10 @@ impl<'a, 'b> FixedRuleInputRelation<'a, 'b> { } impl<'a, 'b> FixedRulePayload<'a, 'b> { + /// Get the total number of input relations. + pub fn inputs_count(&self) -> usize { + self.manifest.relations_count() + } /// Get the input relation at `idx`. pub fn get_input(&self, idx: usize) -> Result> { let arg_manifest = self.manifest.relation(idx)?;