WorkingMemory

Struct WorkingMemory 

Source
pub struct WorkingMemory { /* private fields */ }
Expand description

Working Memory - stores and manages facts (Drools-style)

Implementations§

Source§

impl WorkingMemory

Source

pub fn new() -> Self

Create a new empty working memory

Source

pub fn insert(&mut self, fact_type: String, data: TypedFacts) -> FactHandle

Insert a fact into working memory (returns FactHandle)

Source

pub fn update( &mut self, handle: FactHandle, data: TypedFacts, ) -> Result<(), String>

Update a fact in working memory

Source

pub fn retract(&mut self, handle: FactHandle) -> Result<(), String>

Retract (delete) a fact from working memory

Source

pub fn get(&self, handle: &FactHandle) -> Option<&WorkingMemoryFact>

Get a fact by handle

Source

pub fn get_by_type(&self, fact_type: &str) -> Vec<&WorkingMemoryFact>

Get all facts of a specific type

Source

pub fn get_all_facts(&self) -> Vec<&WorkingMemoryFact>

Get all facts

Source

pub fn get_all_handles(&self) -> Vec<FactHandle>

Get all fact handles

Source

pub fn get_modified_handles(&self) -> &HashSet<FactHandle>

Get modified handles since last clear

Source

pub fn get_retracted_handles(&self) -> &HashSet<FactHandle>

Get retracted handles since last clear

Source

pub fn clear_modification_tracking(&mut self)

Clear modification tracking (after propagation)

Source

pub fn stats(&self) -> WorkingMemoryStats

Get statistics

Source

pub fn clear(&mut self)

Clear all facts

Source

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§

Source§

impl Default for WorkingMemory

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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.