Struct polar_core::kb::KnowledgeBase
source · [−]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
sourceimpl 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>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
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.
pub fn clear_rules(&mut self)
pub fn rewrite_shorthand_rules(&mut self) -> Vec<PolarError>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn create_resource_specific_rule_types(&mut self) -> PolarResult<()>
pub fn is_union(&self, maybe_union: &Term) -> bool
pub fn get_union_members(&self, union: &Term) -> &HashSet<Term>
pub fn has_rules(&self) -> bool
Trait Implementations
sourceimpl Default for KnowledgeBase
impl Default for KnowledgeBase
sourcefn default() -> KnowledgeBase
fn default() -> KnowledgeBase
Returns the “default value” for a type. Read more
Auto Trait Implementations
impl RefUnwindSafe for KnowledgeBase
impl Send for KnowledgeBase
impl Sync for KnowledgeBase
impl Unpin for KnowledgeBase
impl UnwindSafe for KnowledgeBase
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more