use pg::dyn::{Value, Type};
pub type CacheId = i64;
pub type FactId = i32;
use engine::types::{Fact, Clause, Predicate};
use std::result::Result;
pub trait FactDB {
type Error: ::std::error::Error;
fn insert_fact(&self, fact: &Fact) -> Result<bool, Self::Error>;
fn add_type(&self, type_: Type) -> Result<(), Self::Error>;
fn get_type(&self, type_str: &str) -> Option<Type>;
fn get_predicate(&self, pred_name: &str) -> Option<Predicate>;
fn new_predicate(&self, pred: &Predicate) -> Result<(), Self::Error>;
fn new_rule_cache(&self, pred: Vec<String>) -> Result<CacheId, Self::Error>;
fn cache_hit(&self, cache: CacheId, Vec<FactId>) -> Result<(), Self::Error>;
fn search_facts(&self,
query: &Vec<Clause>,
cache: Option<CacheId>)
-> Result<Vec<(Vec<FactId>, Vec<Value>)>, Self::Error>;
}