Skip to main content

MemStore

Struct MemStore 

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

A simple in-memory implementation of Store. Supports semi-naive evaluation by tracking “stable” and “delta” facts.

Implementations§

Source§

impl MemStore

Source

pub fn new() -> Self

Source

pub fn create_relation(&mut self, relation: &str)

Registers a relation (creating it if absent) to allow scanning it.

Source

pub fn add_fact(&mut self, relation: &str, args: Vec<Value>)

Add a fact manually (for testing/setup). Auto-creates relation in stable.

Source

pub fn get_facts(&self, relation: &str) -> Vec<Vec<Value>>

Trait Implementations§

Source§

impl Default for MemStore

Source§

fn default() -> MemStore

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

impl Store for MemStore

Source§

fn scan( &self, relation: &str, ) -> Result<Box<dyn Iterator<Item = Vec<Value>> + '_>>

Returns an iterator over all tuples in the relation. Returns an error if the relation does not exist.
Source§

fn scan_delta( &self, relation: &str, ) -> Result<Box<dyn Iterator<Item = Vec<Value>> + '_>>

Returns an iterator over only the new tuples added in the last iteration.
Source§

fn scan_next_delta( &self, relation: &str, ) -> Result<Box<dyn Iterator<Item = Vec<Value>> + '_>>

Returns an iterator over tuples being collected for the next iteration.
Source§

fn scan_index( &self, relation: &str, col_idx: usize, key: &Value, ) -> Result<Box<dyn Iterator<Item = Vec<Value>> + '_>>

Returns an iterator over tuples in the relation matching a key in a column.
Source§

fn scan_delta_index( &self, relation: &str, col_idx: usize, key: &Value, ) -> Result<Box<dyn Iterator<Item = Vec<Value>> + '_>>

Returns an iterator over delta tuples matching a key in a column.
Source§

fn insert(&mut self, relation: &str, tuple: Vec<Value>) -> Result<bool>

Inserts a tuple into the relation (specifically into the delta/new set). Returns true if it was new.
Source§

fn merge_deltas(&mut self)

Merges current deltas into the stable set of facts.
Source§

fn create_relation(&mut self, relation: &str)

Ensures a relation exists in the store.
Source§

fn retract(&mut self, relation: &str, tuple: &[Value]) -> Result<bool>

Removes a specific tuple from the relation’s stable set. Returns true if the tuple was found and removed.
Source§

fn clear(&mut self, relation: &str)

Removes all tuples from a relation (stable, delta, and next_delta).
Source§

fn relation_names(&self) -> Vec<String>

Returns the names of all relations in the store.

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.