pub struct Facts { /* private fields */ }Expand description
Facts - represents the working memory of data objects Similar to Grule’s DataContext concept
Implementations§
Source§impl Facts
impl Facts
Sourcepub fn create_object(pairs: Vec<(String, Value)>) -> Value
pub fn create_object(pairs: Vec<(String, Value)>) -> Value
Create a generic object from key-value pairs
Sourcepub fn add<T>(&self, name: &str, fact: T) -> Result<()>
pub fn add<T>(&self, name: &str, fact: T) -> Result<()>
Add a fact object to the working memory
Sourcepub fn get_nested(&self, path: &str) -> Option<Value>
pub fn get_nested(&self, path: &str) -> Option<Value>
Get a nested fact property (e.g., “User.Profile.Age”)
Sourcepub fn get_fact_names(&self) -> Vec<String>
pub fn get_fact_names(&self) -> Vec<String>
Get all fact names
Sourcepub fn get_all_facts(&self) -> HashMap<String, Value>
pub fn get_all_facts(&self) -> HashMap<String, Value>
Get all facts as a HashMap (for pattern matching evaluation)
Sourcepub fn get_fact_type(&self, name: &str) -> Option<String>
pub fn get_fact_type(&self, name: &str) -> Option<String>
Get the type name of a fact
Sourcepub fn to_context(&self) -> Context
pub fn to_context(&self) -> Context
Convert to Context for rule evaluation
Sourcepub fn from_context(context: Context) -> Self
pub fn from_context(context: Context) -> Self
Create Facts from Context
Sourcepub fn snapshot(&self) -> FactsSnapshot
pub fn snapshot(&self) -> FactsSnapshot
Get a snapshot of all facts
Sourcepub fn restore(&self, snapshot: FactsSnapshot)
pub fn restore(&self, snapshot: FactsSnapshot)
Restore from a snapshot
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Facts
impl RefUnwindSafe for Facts
impl Send for Facts
impl Sync for Facts
impl Unpin for Facts
impl UnwindSafe for Facts
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