Trait Primitive

Source
pub trait Primitive {
    // Required methods
    fn name(&self) -> &str;
    fn get_type_constraints(&self, span: &Span) -> Box<dyn TypeConstraint>;
    fn apply(
        &self,
        exec_state: &mut ExecutionState<'_>,
        args: &[Value],
    ) -> Option<Value>;
}
Expand description

A trait for implementing custom primitive operations in egglog.

Primitives are built-in functions that can be called in both rule queries and actions.

Required Methods§

Source

fn name(&self) -> &str

Returns the name of this primitive operation.

Source

fn get_type_constraints(&self, span: &Span) -> Box<dyn TypeConstraint>

Constructs a type constraint for the primitive that uses the span information for error localization.

Source

fn apply( &self, exec_state: &mut ExecutionState<'_>, args: &[Value], ) -> Option<Value>

Applies the primitive operation to the given arguments.

Returns Some(value) if the operation succeeds, or None if it fails.

Implementors§