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§
Sourcefn set(&mut self, ident: Identifier, value: Val) -> Result<Option<Val>, String>
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).
Sourcefn get(&self, ident: &Identifier) -> Option<Val>
fn get(&self, ident: &Identifier) -> Option<Val>
Retrieves the value for a particular identifier, if exists.