pub struct WorkingMemory { /* private fields */ }Expand description
Working Memory - stores and manages facts (Drools-style)
Implementations§
Source§impl WorkingMemory
impl WorkingMemory
Sourcepub fn insert(&mut self, fact_type: String, data: TypedFacts) -> FactHandle
pub fn insert(&mut self, fact_type: String, data: TypedFacts) -> FactHandle
Insert a fact into working memory (returns FactHandle)
Sourcepub fn update(
&mut self,
handle: FactHandle,
data: TypedFacts,
) -> Result<(), String>
pub fn update( &mut self, handle: FactHandle, data: TypedFacts, ) -> Result<(), String>
Update a fact in working memory
Sourcepub fn retract(&mut self, handle: FactHandle) -> Result<(), String>
pub fn retract(&mut self, handle: FactHandle) -> Result<(), String>
Retract (delete) a fact from working memory
Sourcepub fn get(&self, handle: &FactHandle) -> Option<&WorkingMemoryFact>
pub fn get(&self, handle: &FactHandle) -> Option<&WorkingMemoryFact>
Get a fact by handle
Sourcepub fn get_by_type(&self, fact_type: &str) -> Vec<&WorkingMemoryFact>
pub fn get_by_type(&self, fact_type: &str) -> Vec<&WorkingMemoryFact>
Get all facts of a specific type
Sourcepub fn get_all_facts(&self) -> Vec<&WorkingMemoryFact>
pub fn get_all_facts(&self) -> Vec<&WorkingMemoryFact>
Get all facts
Sourcepub fn get_all_handles(&self) -> Vec<FactHandle>
pub fn get_all_handles(&self) -> Vec<FactHandle>
Get all fact handles
Sourcepub fn get_modified_handles(&self) -> &HashSet<FactHandle>
pub fn get_modified_handles(&self) -> &HashSet<FactHandle>
Get modified handles since last clear
Sourcepub fn get_retracted_handles(&self) -> &HashSet<FactHandle>
pub fn get_retracted_handles(&self) -> &HashSet<FactHandle>
Get retracted handles since last clear
Sourcepub fn clear_modification_tracking(&mut self)
pub fn clear_modification_tracking(&mut self)
Clear modification tracking (after propagation)
Sourcepub fn stats(&self) -> WorkingMemoryStats
pub fn stats(&self) -> WorkingMemoryStats
Get statistics
Sourcepub fn to_typed_facts(&self) -> TypedFacts
pub fn to_typed_facts(&self) -> TypedFacts
Flatten all facts into a single TypedFacts for evaluation Each fact’s fields are prefixed with “type.handle.”
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for WorkingMemory
impl RefUnwindSafe for WorkingMemory
impl Send for WorkingMemory
impl Sync for WorkingMemory
impl Unpin for WorkingMemory
impl UnwindSafe for WorkingMemory
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