Trait MemoryStore

Source
pub trait MemoryStore<Val> {
    // Required methods
    fn set(
        &mut self,
        ident: Identifier,
        value: Val,
    ) -> Result<Option<Val>, String>;
    fn get(&self, ident: &Identifier) -> Option<Val>;
}
Expand description

Methods for setting and getting values in a memory store. This is used instead of a MemoryTable when a structure (like a scope) may search through multiple memory tables to retrieve the value.

Required Methods§

Source

fn set(&mut self, ident: Identifier, value: Val) -> Result<Option<Val>, String>

Sets (or updates) the value in memory for an identifier. Returns the previous value (if exists). Typically, the identifier should already exist in the store, but may not have an existing value.

§Failures

Can fail if setting value for an identifier that doesn’t otherwise exist in the store (unless this is allowed in a particular implementation).

Source

fn get(&self, ident: &Identifier) -> Option<Val>

Retrieves the value for a particular identifier, if exists.

Implementors§

Source§

impl<Val: Clone, T> MemoryStore<Val> for Scope<T>
where T: MemoryTable<Val>,