Trait swipl::callable::Callable

source ·
pub trait Callable<const N: usize> {
    type ContextType: OpenCall;

    // Required method
    fn open<'a, C: ContextType>(
        self,
        context: &'a Context<'_, C>,
        module: Option<Module>,
        args: [&Term<'_>; N]
    ) -> Context<'a, Self::ContextType>;
}
Expand description

Trait for things that can be called as if they are prolog predicates.

This is obviously the case for prolog predicates themselves, which are implemented through CallablePredicate. The intention though is to also implement frontends for foreign predicates through this trait, so that they may be used as prolog predicates without actually having to go through prolog. However, this is currently not yet implemented.

Through the const generic, this knows about the predicate arity at compile time. This allows context.open(..) to check at compile time that the arity matches.

Required Associated Types§

Required Methods§

source

fn open<'a, C: ContextType>( self, context: &'a Context<'_, C>, module: Option<Module>, args: [&Term<'_>; N] ) -> Context<'a, Self::ContextType>

Object Safety§

This trait is not object safe.

Implementors§