Trait spacetimedb_vm::program::ProgramVm
source · pub trait ProgramVm {
// Required methods
fn env(&self) -> &EnvDb;
fn env_mut(&mut self) -> &mut EnvDb;
fn ctx(&self) -> &dyn ProgramVm;
fn auth(&self) -> &AuthCtx;
fn eval_query(&mut self, query: CrudCode) -> Result<Code, ErrorVm>;
fn as_program_ref(&self) -> ProgramRef<'_>;
// Provided methods
fn load_ops(env: &mut EnvDb)
where Self: Sized { ... }
fn add_lambda(&mut self, f: FunDef, body: Code) { ... }
fn update_lambda(&mut self, f: FunDef, body: Code) { ... }
fn add_ident(&mut self, name: &str, v: Code) { ... }
fn find_ident(&self, key: &str) -> Option<&Code> { ... }
}Expand description
A trait to allow split the execution of programs to allow executing
queries that take in account each program state/enviroment.
In concrete, it allows to run queries that run on the SpaceTimeDb engine.
It could also permite run queries backed by different engines, like in MySql.
Required Methods§
fn env(&self) -> &EnvDb
fn env_mut(&mut self) -> &mut EnvDb
fn ctx(&self) -> &dyn ProgramVm
fn auth(&self) -> &AuthCtx
sourcefn eval_query(&mut self, query: CrudCode) -> Result<Code, ErrorVm>
fn eval_query(&mut self, query: CrudCode) -> Result<Code, ErrorVm>
Allows to execute the query with the state carried by the implementation of this trait
fn as_program_ref(&self) -> ProgramRef<'_>
Provided Methods§
sourcefn load_ops(env: &mut EnvDb)where
Self: Sized,
fn load_ops(env: &mut EnvDb)where Self: Sized,
Load the in-built functions that define the operators of the VM,
like +, and, ==, etc.
sourcefn add_lambda(&mut self, f: FunDef, body: Code)
fn add_lambda(&mut self, f: FunDef, body: Code)
Add a function that is defined natively by Code
fn update_lambda(&mut self, f: FunDef, body: Code)
sourcefn add_ident(&mut self, name: &str, v: Code)
fn add_ident(&mut self, name: &str, v: Code)
Add a ident into the environment, similar to let x = expr
sourcefn find_ident(&self, key: &str) -> Option<&Code>
fn find_ident(&self, key: &str) -> Option<&Code>
Locates the ident in the environment