pub struct Predicate { /* private fields */ }Expand description
Predicate type and runtime behavior.
Predicates can be instantiated as atoms, can inherit from parent predicates, and execute associated statements for each atom invocation.
Implementations§
Source§impl Predicate
impl Predicate
Sourcepub fn new(
core: Weak<dyn Core>,
scope: Option<Weak<dyn Scope>>,
predicate: PredicateDef,
) -> Rc<Self>
pub fn new( core: Weak<dyn Core>, scope: Option<Weak<dyn Scope>>, predicate: PredicateDef, ) -> Rc<Self>
Creates a predicate from its parsed definition.
pub fn parents(&self) -> &[Vec<String>]
pub fn args(&self) -> &[(Vec<String>, String)]
pub fn statements(&self) -> &[Statement]
Sourcepub fn new_atom(
self: Rc<Self>,
fact: bool,
args: HashMap<String, Rc<dyn Var>>,
) -> Rc<Atom>
pub fn new_atom( self: Rc<Self>, fact: bool, args: HashMap<String, Rc<dyn Var>>, ) -> Rc<Atom>
Registers a new atom for this predicate and all declared parent predicates.
Sourcepub fn call(self: Rc<Self>, atom: Rc<Atom>) -> Result<(), RiddleError>
pub fn call(self: Rc<Self>, atom: Rc<Atom>) -> Result<(), RiddleError>
Executes predicate statements against a concrete atom.
pub fn atoms(&self) -> Vec<Rc<Atom>>
Trait Implementations§
Source§impl Scope for Predicate
impl Scope for Predicate
fn core(self: Rc<Self>) -> Rc<dyn Core>
fn scope(&self) -> Option<Rc<dyn Scope>>
fn get_field(&self, name: &str) -> Option<Rc<Field>>
fn get_method(&self, name: &str, classes: &[Rc<dyn Type>]) -> Option<Rc<Method>>
fn get_type(&self, name: &str) -> Option<Rc<dyn Type>>
fn get_predicate(&self, name: &str) -> Option<Rc<Predicate>>
fn as_class(self: Rc<Self>) -> Option<Rc<dyn Class>>
Auto Trait Implementations§
impl !Freeze for Predicate
impl !RefUnwindSafe for Predicate
impl !Send for Predicate
impl !Sync for Predicate
impl Unpin for Predicate
impl UnsafeUnpin for Predicate
impl !UnwindSafe for Predicate
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more