pub trait FixedRule: Send + Sync {
// Required methods
fn arity(
&self,
options: &BTreeMap<SmartString<LazyCompact>, Expr>,
rule_head: &[Symbol],
span: SourceSpan,
) -> Result<usize>;
fn run(
&self,
payload: FixedRulePayload<'_, '_>,
out: &mut RegularTempStore,
poison: Poison,
) -> Result<()>;
// Provided method
fn init_options(
&self,
_options: &mut BTreeMap<SmartString<LazyCompact>, Expr>,
_span: SourceSpan,
) -> Result<()> { ... }
}Expand description
Trait for an implementation of an algorithm or a utility
Required Methods§
Sourcefn arity(
&self,
options: &BTreeMap<SmartString<LazyCompact>, Expr>,
rule_head: &[Symbol],
span: SourceSpan,
) -> Result<usize>
fn arity( &self, options: &BTreeMap<SmartString<LazyCompact>, Expr>, rule_head: &[Symbol], span: SourceSpan, ) -> Result<usize>
You must return the row width of the returned relation and it must be accurate. This function may be called multiple times.
Sourcefn run(
&self,
payload: FixedRulePayload<'_, '_>,
out: &mut RegularTempStore,
poison: Poison,
) -> Result<()>
fn run( &self, payload: FixedRulePayload<'_, '_>, out: &mut RegularTempStore, poison: Poison, ) -> Result<()>
You should implement the logic of your algorithm/utility in this function.
The outputs are written to out. You should check poison periodically
for user-initiated termination.
Provided Methods§
Sourcefn init_options(
&self,
_options: &mut BTreeMap<SmartString<LazyCompact>, Expr>,
_span: SourceSpan,
) -> Result<()>
fn init_options( &self, _options: &mut BTreeMap<SmartString<LazyCompact>, Expr>, _span: SourceSpan, ) -> Result<()>
Called to initialize the options given. Will always be called once, before anything else. You can mutate the options if you need to. The default implementation does nothing.