pub unsafe trait OpenCall: Sized {
// Required methods
fn next_solution(this: &Context<'_, Self>) -> PrologResult<bool>;
fn cut(this: Context<'_, Self>);
fn discard(this: Context<'_, Self>);
}
Expand description
An open call.
A context that wraps an open call can be asked for the next
solution, or close itself through cutting the query or
discarding. All these functions are actually implemented here
using the OpenCall
trait.
This context type is the only type where new terms are not allowed to be created, nor is it allowed to start new queries directly from this context. This is because SWI-Prolog really doesn’t like it if the prolog stack changes between solutions. It is still possible however to open a new frame and do all that stuff in the new frame. You’ll need to close the frame before continuing with solution retrieval.
Safety
A type implementing OpenCall automatically becomes a ContextType as well, so all the safety concerns regarding ContextType apply here too.
Required Methods§
sourcefn next_solution(this: &Context<'_, Self>) -> PrologResult<bool>
fn next_solution(this: &Context<'_, Self>) -> PrologResult<bool>
Retrieve the next solution.
If solution retrieval led to a failure or an error, this is
returned in the Err
part of the PrologResult
. Otherwise,
Ok(true)
is returned if there are more solutions, and
Ok(false)
is returned when this is the last solution.