Skip to main content

Predicate

Struct Predicate 

Source
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

Source

pub fn new( core: Weak<dyn Core>, scope: Option<Weak<dyn Scope>>, predicate: PredicateDef, ) -> Rc<Self>

Creates a predicate from its parsed definition.

Source

pub fn parents(&self) -> &[Vec<String>]

Source

pub fn args(&self) -> &[(Vec<String>, String)]

Source

pub fn statements(&self) -> &[Statement]

Source

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.

Source

pub fn call(self: Rc<Self>, atom: Rc<Atom>) -> Result<(), RiddleError>

Executes predicate statements against a concrete atom.

Source

pub fn atoms(&self) -> Vec<Rc<Atom>>

Trait Implementations§

Source§

impl Debug for Predicate

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Scope for Predicate

Source§

fn core(self: Rc<Self>) -> Rc<dyn Core>

Source§

fn scope(&self) -> Option<Rc<dyn Scope>>

Source§

fn get_field(&self, name: &str) -> Option<Rc<Field>>

Source§

fn get_method(&self, name: &str, classes: &[Rc<dyn Type>]) -> Option<Rc<Method>>

Source§

fn get_type(&self, name: &str) -> Option<Rc<dyn Type>>

Source§

fn get_predicate(&self, name: &str) -> Option<Rc<Predicate>>

Source§

fn as_class(self: Rc<Self>) -> Option<Rc<dyn Class>>

Source§

impl Type for Predicate

Source§

fn name(&self) -> &str

Source§

fn full_name(&self) -> String

Source§

fn as_any(self: Rc<Self>) -> Rc<dyn Any>

Source§

fn as_predicate(self: Rc<Self>) -> Option<Rc<Predicate>>

Source§

fn new_instance(self: Rc<Self>) -> Rc<dyn Var>

Source§

fn as_class(self: Rc<Self>) -> Option<Rc<dyn Class>>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.