Struct holmes::engine::Engine
[−]
[src]
pub struct Engine<FE: Error + Send + 'static, FDB: FactDB<Error = FE>> { /* fields omitted */ }
The Engine
type contains the context necessary to run a Holmes program
Methods
impl<FE, FDB> Engine<FE, FDB> where
FE: Error + Send + 'static,
FDB: FactDB<Error = FE>,
[src]
FE: Error + Send + 'static,
FDB: FactDB<Error = FE>,
fn new(db: FDB, handle: Handle) -> Self
Create a fresh engine by handing it a fact database to use
fn get_type(&self, name: &str) -> Option<Type>
Seach the type registry for a named type
If present, it returns Some(type)
, otherwise None
fn add_type(&self, type_: Type) -> Result<()>
Register a new type
This type must be a named type (e.g. type.name() should return Some
)
fn new_predicate(&self, pred: &Predicate) -> Result<()>
Register a new predicate This defines the type signature of a predicate and persists it
- Predicates must have at least one argument
- Predicates must have a unique name
- While using the
pg
backend, their name must be lowercase ascii or '_'
fn get_predicate(&self, name: &str) -> Result<Option<Predicate>>
Retrieves a named predicate from the database. This is primarily of use for retrieving metadata about a predicate for display.
fn new_fact(&mut self, fact: &Fact) -> Result<()>
Adds a new fact to the database If the fact is already present, a new copy will not be added.
- The relevant predicate must already be registered
- The fact must be correctly typed
fn nop(&self) -> Result<()>
Returns success in the appropriate type. This helper function is to support the EDSL, and it is not anticipated to be useful normally.
fn derive(&self, query: &Vec<Clause>) -> Result<Vec<Vec<Value>>>
Given a query (similar to the rhs of a rule in Datalog), provide the set of satisfying answers in the database.
fn render(&self, pred_name: &String) -> Result<String>
Render a predicate as an html table
fn new_rule(&mut self, rule: &Rule) -> Result<()> where
FDB: 'static,
FDB: 'static,
Register a new rule with the database
fn reg_func(&mut self, name: String, func: Func) -> Result<()>
Register a new function with the database, to be called from within a rule
Do not attempt to register a function name multiple times.
fn quiesce(&self) -> Quiescence
Creates a quiescence future to be run on the event loop provided when the engine was created. The future will only gaurantee quiescence upon completion so long as no new rules have been added.