pub struct Predicate { /* private fields */ }
Expand description
A wrapper for a prolog predicate.
Implementations§
source§impl Predicate
impl Predicate
sourcepub unsafe fn wrap(predicate: predicate_t) -> Self
pub unsafe fn wrap(predicate: predicate_t) -> Self
Wrap a predicate_t
, which is how the SWI-Prolog fli represents predicates.
Safety
This is unsafe because no check is done to ensure that the predicate_t indeed points at a valid predicate. The caller will have to ensure that this is the case.
sourcepub fn new(functor: Functor, module: Module) -> Self
pub fn new(functor: Functor, module: Module) -> Self
Create a new predicate from the given functor and module.
This will panic if no prolog engine is active on this thread.
sourcepub fn predicate_ptr(&self) -> predicate_t
pub fn predicate_ptr(&self) -> predicate_t
Return the underlying predicate_t
which SWI-Prolog uses to refer to the predicate.
sourcepub fn with_name<F, R>(&self, func: F) -> R
pub fn with_name<F, R>(&self, func: F) -> R
Retrieve the name of this predicate as an atom and pass it into the given function.
The atom does not outlive this call, and the reference count is never incremented. This may be slightly faster in some cases than returning the name directly.
This will panic if no prolog engine is active on this thread.
sourcepub fn name(&self) -> Atom
pub fn name(&self) -> Atom
Retrieve the name of this predicate as an atom.
This will panic if no prolog engine is active on this thread.
sourcepub fn name_string(&self) -> String
pub fn name_string(&self) -> String
Retrieve the name of this predicate as a string.
This will panic if no prolog engine is active on this thread.