pub struct KnowledgeBase {
pub mro: HashMap<Symbol, Vec<u64>>,
pub inline_queries: Vec<Term>,
pub resource_blocks: ResourceBlocks,
/* private fields */
}
Fields§
§mro: HashMap<Symbol, Vec<u64>>
Map of class name -> MRO list where the MRO list is a list of class instance IDs
inline_queries: Vec<Term>
§resource_blocks: ResourceBlocks
Resource block bookkeeping.
Implementations§
Source§impl KnowledgeBase
impl KnowledgeBase
pub fn new() -> Self
Sourcepub fn new_id(&self) -> u64
pub fn new_id(&self) -> u64
Return a monotonically increasing integer ID.
Wraps around at 52 bits of precision so that it can be safely coerced to an IEEE-754 double-float (f64).
pub fn id_counter(&self) -> Counter
Sourcepub fn temp_prefix(name: &str) -> String
pub fn temp_prefix(name: &str) -> String
Generate a temporary variable prefix from a variable name.
pub fn add_rule(&mut self, rule: Rule)
pub fn validate_rules(&self) -> Vec<Diagnostic>
pub fn get_rules(&self) -> &HashMap<Symbol, GenericRule>
pub fn get_generic_rule(&self, name: &Symbol) -> Option<&GenericRule>
pub fn add_rule_type(&mut self, rule_type: Rule)
Sourcepub fn register_constant(
&mut self,
name: Symbol,
value: Term,
) -> PolarResult<()>
pub fn register_constant( &mut self, name: Symbol, value: Term, ) -> PolarResult<()>
Define a constant variable.
Error on attempts to register the “union” types (Actor & Resource) since those types have special meaning in policies that use resource blocks.
Sourcepub fn is_constant(&self, name: &Symbol) -> bool
pub fn is_constant(&self, name: &Symbol) -> bool
Return true if a constant with the given name has been defined.
Sourcepub fn get_registered_constants(&self) -> &Bindings
pub fn get_registered_constants(&self) -> &Bindings
Getter for constants
map without exposing it for mutation.
pub fn get_registered_class(&self, class: &Term) -> PolarResult<&Term>
Sourcepub fn add_mro(&mut self, name: Symbol, mro: Vec<u64>) -> PolarResult<()>
pub fn add_mro(&mut self, name: Symbol, mro: Vec<u64>) -> PolarResult<()>
Add the Method Resolution Order (MRO) list for a registered class.
The mro
argument is a list of the instance_id
associated with a registered class.